Part Number Hot Search : 
L1027 11411100 3R3YZF OM7662 0V8X20 EB13E2J2 BA6161F X1205S8I
Product Description
Full Text Search
 

To Download ST92T163 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  january 2000 1/224 this is preliminary information on a new product in development orundergoing evaluation. details are subject to change without notice. st92163 8/16-bit full speed usb mcu for composite devices with 16 endpoints, 20k rom, 2k ram, i 2 c, sci, & mft preliminary data n internal memories: 20 kbytes rom/eprom/ otp, 2 kbytes ram n register oriented 8/16 bit core n 224 general purpose registers available as ram, accumulators or index pointers n minimum instruction cycle time: 167 ns (@24 mhz cpu frequency) n low power modes: wfi, slow, halt and stop n dma controller for reduced processor overhead n full speed usb interface with dma, compliant with usb specifications version 1.1 (in normal voltage mode) n usb embedded functions with 16 fully configurable endpoints (buffer size programmable), supporting all usb data transfer types (isochronous included) n on-chip usb transceiver and 3.3 voltage regulator n multimaster i 2 c-bus serial interface up to 400khz. with dma capability n serial communications interface (sci) with dma capability: asynchronous mode up to 315 kb/s synchronous mode up to 3 mhz n external memory interface (8-bit data/16-bit address) with dma capability from the usb n 16-bit multi-function timer (12 operating modes) with dma capability n 16-bit timer with 8-bit prescaler and watchdog n 6-channel, 8-bit a/d converter (adc) n 15 interrupt pins on 8 interrupt channels n 14 pins programmable as wake-up or additional external interrupts n 42 (dip56) or 44 (qfp64) fully programmable i/os with 6 or 8 high sink pads (10 ma @ 1 v) n programmable pll clock generator (rccu) using a low frequency external quartz (8 mhz) n on-chip rc oscillator for low power operation n low voltage detector reset on some devices 1 n rich instruction set with 14 addressing modes n several operating voltage modes available on some devices 1 : normal voltage mode 8-mhz low voltage mode 16-mhz low voltage mode n 0 - 24 mhz cpu clock operation @ 4.0-5.5 v (all devices) n 0 - 8 mhz cpu clock operation @ 3.0-4.0 v (8- mhz and 16-mhz low voltage devices) n 0 - 16 mhz cpu clock operation @ 3.0-4.0 v (16-mhz low voltage devices only) n division-by-zero trap generation n 0 o cto70 o c temperature range n low emi design supporting single sided pcb n complete development tools, including assembler, linker, c-compiler, archiver, source level debugger and hardware emulators, and real time operating system note 1 : refer to adevice summaryo on page 6 1 tqfp64 psdip56 rev. 1.9
2/224 table of contents st92163 ............................................1 1 general description . . . . . . ................................................ 6 1.1 introduction . . . . . . . . . . . . . ............................................ 6 1.1.1 core architecture . . . . . . . . . . . . . . . . . .................................. 9 1.1.2 instruction set . . . . . . . . . . . . . . . . . . . . .................................. 9 1.1.3 external memory interface . . . . . . . . . . . . . . . . . . . . . . . . . . . ............ 9 1.1.4 operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1.1.5 on-chip peripherals . . . . . . . . . . . . . . . . . . . . . . . . . . . . .................... 10 1.2 pin description . . .................................................... 11 1.3 i/o port pins . . . . . . . . . . . . . . . . . ........................................ 13 1.4 memory map . . . . . . . . . . ........................................... .... 19 1.5 st92163 register map ............................. ................... 20 2 device architecture . . . . . . . . . . ........................................... 27 2.1 core architecture . . . . . . . . . . . . . . . . . . ................................ 27 2.2 memory spaces . . . . . . . . . . . . . . ........................................ 27 2.2.1 register file . . . . . . . . . . . . . . . . . . . . . . . . .............................. 27 2.2.2 register addressing . . . . . ........................................... 29 2.3 system registers . . . . . . . . . . . . . . . . . . . . . . .............................. 30 2.3.1 central interrupt control register . . . . . . . . . . . ........................... 30 2.3.2 flag register . . . . . . ............................................... 31 2.3.3 register pointing techniques . ........................................ 32 2.3.4 paged registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 2.3.5 mode register . . . . . ............................................... 35 2.3.6 stack pointers . . . . . . . . . . . . . . . . . . . . . ................................ 36 2.4 memory organization . . . . . . . . . . . . . . . ................................. 38 2.5 memory management unit . . . . . . . . . . .................................. 39 2.6 address space extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 2.6.1 addressing 16-kbyte pages . . . . . . . . . ............................. .... 40 2.6.2 addressing 64-kbyte segments . . . . . .................................. 41 2.7 mmu registers . ...................................................... 41 2.7.1 dpr[3:0]: data page registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . ........... 41 2.7.2 csr: code segment register ........................................ 43 2.7.3 isr: interrupt segment register . . . . . . . . . .............................. 43 2.7.4 dmasr: dma segment register . . . . . . . . .............................. 43 2.8 mmu usage . . . . . . . . . . . . . . . . . . . . . . . . . . ................................. 45 2.8.1 normal program execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . ............... 45 2.8.2 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . .............................. 45 2.8.3 dma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ........................... 45 3 interrupts . . ......................... .................................... 46 3.1 introduction . . . . . . . . . . . . . ........................................... 46 3.2 interrupt vectoring ................................................ 47 3.2.1 divide by zero trap . . . . . . . . . . . . . . . . ................................. 47 3.2.2 segment paging during interrupt routines . ......................... .... 48 3.3 interrupt priority levels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
3/224 table of contents 224 3.4 priority level arbitration . . . ........................................ 48 3.4.1 priority level 7 (lowest) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 3.4.2 maximum depth of nesting . . . ........................................ 48 3.4.3 simultaneous interrupts . . . . . . . . . . . . ................................. 48 3.4.4 dynamic priority level modification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 3.5 arbitration modes . . . . . . . . . . . . . . . . . .................................. 49 3.5.1 concurrent mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 3.5.2 nested mode . . . . . . ............................................... 52 3.6 external interrupts . . . . . . . . . . . . . . . . . . .............................. 54 3.7 management of wake-up lines and external interrupt lines . ........ 56 3.8 top level interrupt . . . . . . . . . . . . . . . . . ................................ 57 3.9 on-chip peripheral interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . ........... 57 3.10 interrupt response time . ........................................... 58 3.11 interrupt registers . . ........................................... .... 59 3.12 wake-up / interrupt lines management unit (wuimu) . . . . . . . . . . . . . . . . . . 63 3.12.1 introduction . . . . . . . . . . . . . . . ........................................ 63 3.12.2 main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ........ 63 3.12.3 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 3.12.4 programming considerations . . . . . . . . . . . . . . . . . . . . . . . . . . ............... 66 3.12.5 register description . ............................................... 67 4 on-chip direct memory access (dma) . . . . .................................. 70 4.1 introduction . . . . . . . . . . . . . ........................................... 70 4.2 dma priority levels . . . ........................................... .... 70 4.3 dma transactions . . . . . . . . . . . ........................................ 71 4.4 dma cycle time . . . . . . . . . . . . . . . ........................................ 73 4.5 swap mode . . . . . . . . . . . . ........................................... .... 73 4.6 dma registers . . . . . . . . . . . . ........................................... 74 5 reset and clock control unit (rccu) . . . ............................. .... 75 5.1 introduction . . . . . . . . . . . . . ........................................... 75 5.2 clock control unit . . . . . . . ........................................... 75 5.2.1 clock control unit overview . . ........................................ 75 5.3 clock management . . . . . . . . . . ........................................ 77 5.3.1 pll clock multiplier programming . . . . ............................. .... 78 5.3.2 cpu clock prescaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 5.3.3 peripheral clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 5.3.4 low power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ........ 79 5.3.5 interrupt generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . .................... 79 5.4 clock control registers . . . . . . . . . . . . . . .............................. 81 5.5 oscillator characteristics . . . . . . . . . . . .............................. 85 5.6 reset/stop manager . . . . . . ........................................... 86 5.6.1 reset pin timing . . . ............................................... 87 5.7 stop mode . . . . . . . . . . . . . . . . . . . ........................................ 87 5.8 low voltage detector (lvd) reset . . ................................. 88
4/224 table of contents 6 external memory interface (extmi) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 6.1 introduction . . . . . . . . . . . . . ........................................... 89 6.2 external memory signals . . . . . . . . . . . . . . . . . ........................... 90 6.2.1 as: address strobe . . . . . . . . . . . . . . . . . . . . . ........................... 90 6.2.2 ds: data strobe . . . . ........................................... .... 90 6.2.3 ds2: data strobe 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 6.2.4 rw: read/write . . . . ............................................... 93 6.2.5 breq, back: bus request, bus acknowledge . . . . . . . . . . . . . . . . . . . ........ 93 6.2.6 port 0 . . . . . . .................................................... 94 6.2.7 port 1 . . . . . . .................................................... 94 6.2.8 wait: external memory wait . . . . . . . . . . . . . . . . . . . . . . . . . . ............... 94 6.3 register description . ............................................... 95 7 i/o ports . . . . . . . . . . . . . . . . . . . . . . . . . . ........................................ 98 7.1 introduction . . . . . . . . . . . . . ........................................... 98 7.2 specific port configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ........ 98 7.3 port control registers . . . . . . . . . . . . . . . . . . ........................... 98 7.4 input/output bit configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 7.5 alternate function architecture . . . . . . . . . . . . . . . . . . . . . . . . .......... 103 7.5.1 pin declared as i/o . . .............................................. 103 7.5.2 pin declared as an alternate input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 7.5.3 pin declared as an alternate function output . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 7.6 i/o status after wfi, halt and reset . . . . . . . . . . . . . . . . . . . . . . .......... 103 8 on-chip peripherals . . . . . . . . . . . .......................................... 104 8.1 timer/watchdog (wdt) . . . . . . . . . . . . . ................................. 104 8.1.1 introduction . . . . . . . . . . . . .......................................... 104 8.1.2 functional description . . . . . . ....................................... 105 8.1.3 watchdog timer operation . . . . . . . ................................... 106 8.1.4 wdt interrupts ................................................... 108 8.1.5 register description . . . . . .......................................... 109 8.2 multifunction timer (mft) . . . . . . . . . . . . . . . . . . . . . . . . ................... 111 8.2.1 introduction . . . . . . . . . . . . .......................................... 111 8.2.2 functional description . . . . . . ....................................... 113 8.2.3 input pin assignment . . . . . . . . . . . . . ................................. 116 8.2.4 output pin assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 8.2.5 interrupt and dma . . . . . . . . . . . . . . . . ................................ 122 8.2.6 register description . . . . . .......................................... 124 8.3 usb peripheral (usb) . . .............................................. 135 8.3.1 introduction . . . . . . . . . . . . .......................................... 135 8.3.2 main features . . . . . . . . . . .......................................... 135 8.3.3 functional description . . . . . . ....................................... 135 8.3.4 register description . . . . . .......................................... 138 8.3.5 register pages summary . . . . . . . . . . . ................................ 148 8.4 serial communications interface (sci) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 8.4.1 introduction . . . . . . . . . . . . .......................................... 150 8.4.2 functional description . . . . . . ....................................... 151 8.4.3 sci operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
5/224 table of contents 224 8.4.4 serial frame format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 8.4.5 clocks and serial transmission rates . ................................ 158 8.4.6 sci initialization procedure . . . . . . . . . . . . ............................. 158 8.4.7 input signals . . . . . . . . . . . . . . ....................................... 160 8.4.8 output signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....... 160 8.4.9 interrupts and dma . . . . . . . . . ....................................... 161 8.4.10 register description . .............................................. 164 8.5 i2c bus interface . . . . . . . . . . . . . . . . . . . . . . ............................. 175 8.5.1 introduction . . . . . . . . . . . . .......................................... 175 8.5.2 main features . . . . . . . . . . .......................................... 175 8.5.3 functional description . . . . . . ....................................... 176 8.5.4 i2c state machine . . .............................................. 178 8.5.5 interrupt features . . . . . . . . . . ....................................... 183 8.5.6 dma features . . . . . . .............................................. 184 8.5.7 register description . . . . . .......................................... 186 8.6 a/d converter (a/d) . . . . . . . . . . . . . . . . . ................................ 197 8.6.1 introduction . . . . . . . . . . . . .......................................... 197 8.6.2 main features . . . . . . . . . . .......................................... 197 8.6.3 general description . . . . . . . . . . . . . . . . . . ............................. 197 8.6.4 register description . . . . . .......................................... 199 9 electrical characteristics . . . . . . . . . . . . . . . . ............................. 201 10 general information ................................................... 218 10.1 eprom/otp programming . . . . . . . . . . . . . . . . . . . . . . . . . ................... 218 10.2 package description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 10.3 ordering information . . . . . . . . . . . . . ................................. 221 10.4 transfer of customer code . ....................................... 221
6/224 st92163 - general description 1 general description 1.1 introduction the st9216x family brings the enhanced st9 reg- ister-based architecture to a new range of high- performance microcontrollers specifically de- signed for usb (universal serial bus) applica- tions. their performance derives from the use of a flexible 256-register programming model for ultra- fast context switching and real-time event re- sponse. the intelligent on-chip peripherals offload the st9 core from i/o and data management processing tasks allowing critical application tasks to get the maximum use of core resources. the st9 mcu devices support low power consumption and low voltage operation for power-efficient and low-cost embedded systems. in the st92163 fam- ily, four different types of device are available: normal voltage devices with lvd function they operate in normal voltage mode only (4.0- 5.5v @ 24mhz) and include the low voltage de- tector (lvd) function. normal voltage devices without lvd function they operate in normal voltage mode only (4.0- 5.5v @ 24mhz) and do not include the low volt- age detector (lvd) function. 8-mhz low voltage devices they do not include the low voltage detector (lvd) function and they support two operating voltage modes: normal voltage mode (4.0-5.5v @ 24mhz) with full functionality including usb. 8-mhz low voltage mode (3.0-4.0v @ 8mhz) without the usb interface. 16-mhz low voltage devices they do not include the low voltage detector (lvd) function and they support three operating voltage modes: normal voltage mode (4.0-5.5v @ 24mhz) with full functionality including usb. 8-mhz low voltage mode (3.0-4.0v @ 8mhz) without the usb interface. 16-mhz low voltage mode (3.0-4.0v @ 16mhz) without the usb interface. figure 1, on page 7 shows the operating range of the st92163 devices. device summary 1 contact sales office for availability device package program memory ram 16-mhz low voltage mode 8-mhz low voltage mode lvd usb st92163 1 psdip56/ tqfp64 20k rom 2k no no yes yes ST92T163 20k otp st92e163 csdip56/ cqfp64 20k eprom st92163e 1 psdip56/ tqfp64 20k rom no ST92T163e 20k otp st92e163e csdip56/ cqfp64 20k eprom st92163l 1 tqfp64 20k rom yes in normal mode only ST92T163l 20k otp st92e163l cqfp64 20k eprom st92163v 1 tqfp64 20k rom ye s ST92T163v 1 20k otp st92e163v 1 cqfp64 20k eprom
7/224 st92163 - general description introduction (cont'd) figure 1. maximum operating frequency (f max ) versus supply voltage (v dd ) notes: 1) this mode is supported by 16-mhz low voltage devices only 2) this mode is supported by 8-mhz low voltage devices and 16-mhz low voltage devices 3) this mode is supported by all devices 0 2.5 4 4.5 5 5.5 24 20 16 12 8 4 max freque ncy (mhz) supply voltage (v) 3.0 16-mhz low voltage mode 1) functionality is not guaranteed in this area normal voltage mode 3) 8-mhz low voltage mode 2)
8/224 st92163 - general description introduction (cont'd) figure 2. st92163 architectural block diagram *64-pin devices only **on some devices only (refer to adevice summaryo on page 6) watchdog timer 256 bytes register file 2k ram st9+ core 8/16-bit cpu interrupt management memory bus rccu external memory interface register bus a/d converter as back breq ds wait rw p0[7:0] sci 20k rom/ eprom/otp ain[5:0] extrg txclk rxclk sin dcd sout clkout rts sds wdin wdout all alternate functions ( italic characters ) are mapped on ports 0,1, 3, 4, 5 and 6 p3[7:0] p1[7:0] sda scl mf timer usbgnd usbvcc usbdm0 usbdp0 oscin oscout reset intclk i 2 c bus p5[7:0] fully prog. i/os tina tinb touta toutb int[7:0] nmi p4[3:0] p6[5:0] usb with 16 end- points wakeup and interrupt management wkup[14:0] p6[7:6] * a[15:0] d[7:0] usboe dma dma 9v/3.3v voltage regulator low voltage detector lvd** usbsof mirror register
9/224 st92163 - general description introduction (cont'd) 1.1.1 core architecture the nucleus of the st92163 is the enhanced st9 core that includes the central processing unit (cpu), the register file, the interrupt and dma con- troller, and the memory management unit (mmu). three independent buses are controlled by the core: a 22-bit memory bus, an 8-bit register ad- dressing bus and a 6-bit interrupt/dma bus which connects the interrupt and dma controllers in the on-chip peripherals with the core. this multiple bus architecture makes the st9 fam- ily devices highly efficient for accessing on and off-chip memory and fast exchange of data with the on-chip peripherals. the general-purpose registers can be used as ac- cumulators, index registers, or address pointers. adjacent register pairs make up 16-bit registers for addressing or 16-bit processing. although the st9 has an 8-bit alu, the chip handles 16-bit opera- tions, including arithmetic, loads/stores, and mem- ory/register and memory/memory exchanges. many opcodes specify byte or word operations, the hardware automatically handles 16-bit opera- tions and accesses. for interrupts or subroutine calls, the cpu uses a system stack in conjunction with the stack pointer (sp). a separate user stack has its own sp. the separate stacks, without size limitations, can be in on-chip ram (or in register file) or off-chip mem- ory. 1.1.2 instruction set the st9 instruction set consists of 94 instruction types, including instructions for bit handling, byte (8-bit) and word (16-bit) data, as well as bcd and boolean formats. instructions have been added to facilitate large program and data handling through the mmu, as well as to improve the performance and code density of c function calls. 14 address- ing modes are available, including powerful indi- rect addressing capabilities. the bit-manipulation instructions of the st9 are set, clear, complement, test and set, load, and var- ious logic instructions (and, or, and xor). math functions include add, subtract, increment, decre- ment, decimal adjust, multiply and divide. 1.1.3 external memory interface the st92163 device has a 16-bit external address bus allowing it to address up to 64k bytes of exter- nal memory. 1.1.4 operating modes to optimize performance versus the power con- sumption of the device, st9 devices now support a range of operating modes that can be dynami- cally selected depending on the performance and functionality requirements of the application at a given moment. run mode. this is the full speed execution mode with cpu and peripherals running at the maximum clock speed delivered by the phase locked loop (pll) of the clock control unit (ccu). slow mode . power consumption can be signifi- cantly reduced by running the cpu and the periph- erals at reduced clock speed using the cpu pres- caler and ccu clock divider. wait for interrupt mode. the wait for interrupt (wfi) instruction suspends program execution un- til an interrupt request is acknowledged. during wfi, the cpu clock is halted while the peripheral and interrupt controller keep running at a frequen- cy programmable via the ccu. in this mode, the power consumption of the device can be reduced by more than 95% (lp wfi). halt mode. when executing the halt instruction, and if the watchdog is not enabled, the cpu and its peripherals stop operating and the status of the machine remains frozen (the clock is also stopped). a reset is necessary to exit from halt mode. stop mode. under user program control, (see wake-up and interrupt management unit), the cpu and its peripherals stop operating and the status of the machine remains frozen (the clock is also stopped) until program execution is woken up by an event on an external wake-up pin.
10/224 st92163 - general description introduction (cont'd) 1.1.5 on-chip peripherals usb interface the usb interface provides a full speed usb 1.1 compliant port with embedded transceiver and voltage regulator. up to 16 endpoints are available supporting up to 8 usb devices. separate transmit and receive dma channels are available for each device for fast data transfers with internal ram. parallel i/o ports the st9 is provided with dedicated lines for input/ output. these lines, grouped into 8-bit ports, can be independently programmed to provide parallel input/output or to carry input/output signals to or from the on-chip peripherals and core. all ports have active pull-ups and pull-down resistors com- patible with ttl loads. in addition pull-ups can be turned off for open drain operation and weak pull- ups can be turned on to save chip resistive pull- ups. input buffers can be either ttl or cmos compatible. high current (10 ma) outputs are available for driving external devices such as leds. multifunction timer the multifunction timer has a 16-bit up/down counter supported by two 16-bit compare regis- ters, two 16-bit input capture registers and two dma channels. timing resolution can be pro- grammed using an 8-bit prescaler. 12 operating modes allow a range of different timing functions to be easily performed such as complex waveform generatation, measurement or pwm output. 16-bit timer/watchdog the timer/watchdog peripheral can be used as a watchdog or for a wide range of other timing func- tions such as generating periodic interrupts, meas- uring input signal pulse widths, requesting an in- terrupt after a set number of events. it can also generate a square wave or pwm output signal. serial communications controller the sci provides a synchronous or asynchronous serial i/o port using two dma channels. baud rates and data formats are programmable. con- troller applications can further benefit from the self test and address wake-up facility offered by the character search mode. i 2 c bus interface the i 2 c bus is a synchronous serial bus for con- necting multiple devices using a data line and a clock line. multimaster and slave modes are sup- ported. data transfer between the bus and memo- ry is performed by dma. the i 2 c interface sup- ports 7 and 10-bit addressing. it operates in multi- master or slave mode and supports speeds of up to 400 khz. bus events (bus busy, slave address recognized) and error conditions are automatically flagged in peripheral registers and interrupts are optionally generated. analog/digital converter the adc provides up to 6 analog inputs with on- chip sample and hold, fast conversion time and 8- bit resolution. conversion can be triggered by a signal from the multifunction timer (mft).
11/224 st92163 - general description 1.2 pin description figure 3. 64-pin package pin-out n.c. = not connected wkup14/a10/p1.2 wkup14/a9/p1.1 wkup14/a8/p1.0 d7/a7/p0.7 d6/a6/p0.6 d5/a5/p0.5 d4/a4/p0.4 d3/a3/p0.3 d2/a2/p0.2 d1/a1/p0.1 d0/a0/p0.0 ain5/p6.7 ain4/p6.6 usbsof/ain3/p6.5 usbsof/ain2/p6.4 wkup13/ain1/p6.3 p1.3/a11/wkup14 p1.4/a12/wkup14 p1.5/a13/wkup14 p1.6/a14/wkup14 p1.7/a15/wkup14 n.c. n.c. v ss v dd p4.0/breq p4.1/wait p4.2 p4.3//back usbdm0 usbdp0 n.c. n.c. usbvcc usbgnd ds p3.0/int7/sout p3.1/int7/rts p3.2/int7/txclk/clkout p3.3/int7/rxclk p3.4/int7/dcd p3.5/int7/sin p3.6/int7/as p3.7/int7/sds v pp reset p5.0/int1/tina n.c. av dd wkup12/ain0/intclk/p6.2 wkup11/scl/extrg/int6/p6.1 wkup10/sda/int5/p6.0 v dd oscin v ss oscout wdout/nmi/p5.7 wkup9/toutb/p5.6 rw/wdin/int0/p5.5 usboe/wkup8/p5.4 touta/int2/p5.3 int3/p5.2 tinb/int4/p5.1 n.c. 1 64 16 32 48 16
12/224 st92163 - general description figure 4. 56-pin package pin-out table 1. power supply pins table 2. primary function pins 156 29 28 p3.4/int7/dcd/wkup4 p3.5/int7/sin/wkup5 p3.6/int7/asn/wkup6 p3.7/int7/sds/wkup7 v pp reset p5.0/int1/ti na p5.1/int4/ti nb p5.2/int3 p5.3/int2/to uta p5.4/wkup8/usboe p5.5/int0/w din/rw p5.6/toutb /wkup9 p5.7/nmi/w dout oscout v ss oscin v dd p6.0/int5/sda/wkup10 p6.1/int6/extrg/scl/wkup11 p6.2/intclk/ain0/wkup12 av dd p6.3/ain1/wkup13 p6.4/ain2/usbsof p6.5/ain3/usbsof p0.0/a0/d0 p0.1/a1/d1 p0.2/a2/d2 wkup3/rxclk/int7/p3.3 wkup2/clkout/txclk/int7/p3.2 wkup1/rts/int7/p3.1 wkup0/sout/int7/p3.0 ds usbgnd usbvcc usbdp0 usbdm0 back/p4.3 p4.2 wait/p4.1 breq/p4.0 v dd v ss wkup14/a15/p1.7 wkup14/a14/p1.6 wkup14/a13/p1.5 wkup14/a12/p1.4 wkup14/a11/p1.3 wkup14/a10/p1.2 wkup14/a9/p1.1 wkup14/a8/p1.0 d7/a7/p0.7 d6/a6/p0.6 d5/a5/p0.5 d4/a4/p0.4 d3/a3/p0.3 name function dip56 qfp64 v dd main power supply voltage (2 pins internally connected) 14 21 39 56 v ss digital circuit ground (2 pins internally connected) 15 23 41 57 av dd analog circuit supply voltage 35 17 v pp eprom programming voltage. must be connected to ground in normal operating mode. 52 36 name function dip56 qfp64 ds data strobe 5 45 oscin oscillator input 40 22 oscout oscillator output 42 24 reset reset to initialize the st9 51 35 usbgnd usb bus ground level 6 46 usbvcc usb voltage regulator output 7 47 usbdm0 usb upstream port data- line 9 51 usbdp0 usb upstream port data+ line 8 50
13/224 st92163 - general description 1.3 i/o port pins all the ports of the device can be programmed as input/output or in input mode, compatible with ttl or cmos levels (except where schmitt trig- ger is present). each bit can be programmed indi- vidually (refer to the i/o ports chapter). ttl/cmos input for all those port bits where no input schmitt trig- ger is implemented, it is always possible to pro- gram the input level as ttl or cmos compatible by programming the relevant pxc2.n control bit. refer i/o ports chapter to the section titled ainput/ output bit configurationo. push-pull/od output the output buffer can be programmed as push- pull or open-drain: attention must be paid to the fact that the open-drain option corresponds only to a disabling of p-channel mos transistor of the buffer itself: it is still present and physically con- nected to the pin. consequently it is not possible to increase the output voltage on the pin over v dd +0.3 volt, to avoid direct junction biasing. pure open-drain output the user can increase the voltage on an i/o pin over v dd +0.3 volt where the p-channel mos tran- sistor is physically absent: this is allowed on all apure open draino pins. of course, in this case the push-pull option is not available and any weak pull-up must implemented externally. table 3. i/o port characteristics legend: wpu = weak pull-up, od = open drain input output weak pull-up reset state port 0[7:0] ttl/cmos push-pull/od yes bidirectional wpu port 1[7:0] ttl/cmos push-pull/od yes bidirectional wpu port 3[7:0] schmitt trigger push-pull/od yes bidirectional wpu port 4[3:0] schmitt trigger push-pull/od yes bidirectional wpu port 5[7:0] schmitt trigger push-pull/od yes bidirectional wpu port 6[1:0] port 6[5:2] port 6.6 port 6.7 schmitt trigger ttl/cmos schmitt trigger ttl/cmos pure open drain with high sink capability push-pull/od with high sink capability push-pull/od with high sink capability push-pull/od with high sink capability no yes no no bidirectional bidirectional wpu bidirectional bidirectional
14/224 st92163 - general description table 4. st92163 alternate functions port name general purpose i/o pin no. alternate functions dip56 qfp64 p0.0 all ports useable for general pur- pose i/o (input, output or bidirec- tional) 31 11 a0/d0 i/o ext. mem. address/data bit 0 p0.1 30 10 a1/d1 i/o ext. mem. address/data bit 1 p0.2 29 9 a2/d2 i/o ext. mem. address/data bit 2 p0.3 28 8 a3/d3 i/o ext. mem. address/data bit 3 p0.4 27 7 a4/d4 i/o ext. mem. address/data bit 4 p0.5 26 6 a5/d5 i/o ext. mem. address/data bit 5 p0.6 25 5 a6/d6 i/o ext. mem. address/data bit 6 p0.7 24 4 a7/d7 i/o ext. mem. address/data bit 7 p1.0 23 3 a8 i/o ext. mem. address bit 8 wkup14 i wakeup line 14 (***) p1.1 22 2 a9 i/o ext. mem. address bit 9 wkup14 i wakeup line 14 (***) p1.2 21 1 a10 i/o ext. mem. address bit 10 wkup14 i wakeup line 14 (***) p1.3 20 64 a11 i/o ext. mem. address bit 11 wkup14 i wakeup line 14 (***) p1.4 19 63 a12 i/o ext. mem. address bit 12 wkup14 i wakeup line 14 (***) p1.5 18 62 a13 i/o ext. mem. address bit 13 wkup14 i wakeup line 14 (***) p1.6 17 61 a14 i/o ext. mem. address bit 14 wkup14 i wakeup line 14 (***) p1.7 16 60 a15 i/o ext. mem. address bit 15 wkup14 i wakeup line 14 (***) p3.0 4 44 wkup0 i wakeup line 0 int7 i external interrupt 7 (*) sout o sci data output p3.1 3 43 wkup1 o wakeup line 1 int7 i external interrupt 7 (*) rts o sci request to send
15/224 st92163 - general description p3.2 all ports useable for general pur- pose i/o (input, output or bidirec- tional) 242 wkup2 i wakeup line 2 int7 i external interrupt 7 (*) txclk i sci transmit ck input clkout o sci clock output p3.3 1 41 wkup3 i wakeup line 3 int7 i external interrupt 7 (*) rxclk i sci receive ck input o p3.4 56 40 wkup4 i wakeup line 4 int7 i external interrupt 7 (*) dcd i sci data carrier detect o p3.5 55 39 wkup5 i wakeup line 5 int7 i external interrupt 7 (*) sin i sci data input o p3.6 54 38 wkup6 i wakeup line 6 int7 i external interrupt 7 (*) as (**) o ext. mem. address strobe p3.7 53 37 wkup7 i wakeup line 7 int7 i external interrupt 7 (*) sds o sci synchronous data send p4.0 13 55 breq i ext. mem. bus request p4.1 12 54 wait i ext. mem. wait input rw o ext. mem. read/write mode select p4.2 11 53 i as (**) o ext. mem. address strobe p4.3 10 52 i back o ext. mem. bus acknow port name general purpose i/o pin no. alternate functions dip56 qfp64
16/224 st92163 - general description p5.0 all ports useable for general pur- pose i/o (input, output or bidirec- tional) 50 34 int1 i external interrupt 1 tina i mf timer input a o p5.1 49 31 int4 i external interrupt 4 tinb i mf timer input b o p5.2 48 30 int3 i external interrupt 3 p5.3 47 29 int2 i external interrupt 2 touta o mf timer output a p5.4 46 28 wkup8 i wakeup line 8 usboe o usb output enable p5.5 45 27 wdin i watchdog timer input int0 i external interrupt 0 rw o ext. mem. read/write mode select p5.6 44 26 wkup9 i wakeup line 9 toutb o mf timer output b p5.7 43 25 nmi i non maskable interrupt wdout o watchdog timer output p6.0 38 20 wkup10 i wakeup line 10 int5 i external interrupt 5 sdai i i 2 c bus data in sdao o i 2 c bus data out p6.1 37 19 wkup11 i wakeup line 11 int6 i external interrupt 6 scli i i 2 c bus clock in extrg i a/d external trigger sclo o i 2 c bus clock out p6.2 36 18 ain0 i a/d analog input 0 wkup12 i wakeup line 12 intclk o internal clock p6.3 34 16 wkup13 i wakeup line 13 ain1 i a/d analog input 1 o port name general purpose i/o pin no. alternate functions dip56 qfp64
17/224 st92163 - general description *eight interrupt lines internally connected to int7 through a boolean and function. ** as cannot be disabled by software if the asaf bit is set (page register 245) once the corre- sponding p3.6 bit is configured as an alternate function output. ***eight wakeup lines internally connected to wkup14 through a boolean and function. note: the reset state of port 0 and port 1 is input, weak pull-up. to interface external memory, the ports must be configured by software as alternate function output. p6.4 all ports useable for general pur- pose i/o (input, output or bidirec- tional) 33 15 ain2 i a/d analog input 2 usbsof o usb sof synchro p6.5 32 14 ain3 i a/d analog input 3 usbsof o usb sof synchro p6.6 - 13 ain4 i a/d analog input 4 o p6.7 - 12 ain5 i a/d analog input 5 o port name general purpose i/o pin no. alternate functions dip56 qfp64
18/224 st92163 - general description how to configure the i/o ports to configure the i/o ports, use the information in table 3 and table 4 and the port bit configuration table in the i/o ports chapter on page 100. i/o note = the hardware characteristics fixed for each port line. inputs: if i/o note = ttl/cmos, either ttl or cmos in- put level can be selected by software. if i/o note = schmitt trigger, selecting cmos or ttl input by software has no effect, the input will always be schmitt trigger. outputs: if i/o note = push-pull, either push pull or open drain can be selected by software. if i/o note = open drain, selecting push-pull by software has no effect, the input will always be open drain. alternate functions (af) = more than one af cannot be assigned to an external pin at the same time: it can be selected as follows, but simultane- ous availability of several functions of one pin is obviously impossible. af inputs: af is selected implicitly by enabling the corre- sponding peripheral. exceptions to this are adc inputs which are selected explicitly as af by soft- ware. af outputs or bidirectional lines: in the case of outputs or i/os, af is selected explicitly by software. example 1: timer/watchdog input af: wdin, port: p5.5, i/o note: input schmitt trig- ger. write the port configuration bits: p5c2.5=1 p5c1.5=0 p5c0.5=1 enable the wdt peripheral by software as de- scribed in the wdt chapter. example 2: timer/watchdog output af: wdout, port: p5.7, i/o note: none write the port configuration bits: p5c2.7=0 p5c1.7=1 p5c0.7=1 example 3: adc input af: ain0, port: p6.2, i/o note: does not apply to adc write the port configuration bits: p6c2.2=1 p6c1.2=1 p6c0.2=1
19/224 st92163 - general description 1.4 memory map figure 5. st92163 memory map segment 20h 64 kbytes 200000h 21ffffh 20c000h 20bfffh 208000h 207fffh 204000h 203fffh page 80 - 16 kbytes page 81 - 16 kbytes page 82 - 16 kbytes page 83 - 16 kbytes 20f800h 20ffffh note: internal ram addresses are ram 2 kbytes reserved internal external memory reserved external memory segment 21h 64 kbytes internal rom/eprom 20ffffh 220000h 3fffffh repeated each 2 kbytes inside segment 20h. lower memory (usually external rom/eprom upper memory (usually external ram mapped 210000h note: the total amount of external memory is 64 kbytes. mapped in segment 1) in segment 23h) 1fffffh 010000h 00ffffh 00c000h 00bfffh 008000h 007fffh 004000h 000000h 003fffh page 0 - 16 kbytes page 1 - 16 kbytes page 2 - 16 kbytes page 3 - 16 kbytes 64 kbytes segment 0 000000h 004fffh rom/eprom 20 kbytes internal
20/224 st92163 - general description 1.5 st92163 register map table 6 contains the map of the group f peripheral pages. the common registers used by each peripheral are listed in table 5. be very careful to correctly program both: the set of registers dedicated to a particular function or peripheral. registers common to other functions. in particular, double-check that any registers with aundefinedo reset values have been correct- ly initialized. warning : note that in the eivr and each ivr reg- ister, all bits are significant. take care when defin- ing base vector addresses that entries in the inter- rupt vector table do not overlap. table 5. common registers figure 6. st92163 register groups function or peripheral common registers sci, mft cicr + nicr + dma registers + i/o port registers adc cicr + nicr + i/o port registers wdt cicr + nicr + external interrupt registers + i/o port registers i/o ports i/o port registers + moder external interrupt interrupt registers + i/o port registers rccu interrupt registers + moder register file system registers 255 240 239 224 223 f e d c b a 9 8 7 6 5 4 3 2 1 0 15 00 paged registers these register groups (16 registers per group) the amount of reserved registers depends on the number of endpoints used in the program. (8 registers are used per endpoint). for usb dma. are potentially reserved
21/224 st92163 - general description table 6. group f pages register map resources available on the st92163 device: register page 0 2 3 4 5 9 101520212443555762 r255 res. res. res. usb endpoints res. mft usb com- mon i2c mmu sci port 9 res. wui mu adc r254 port 3 r253 r252 wcr r251 wdt res. port 6 port 8 r250 r249 r248 res. r247 ext int res. res. r246 port 5 rccu r245 r244 r243 res. mft r242 port 4 r241 res. r240
22/224 st92163 - general description table 7. detailed register map page no. block reg. no. register name description reset value hex. doc. page system i/o port 3:5 r227 p3dr port 3 data register ff 98 r228 p4dr port 4 data register ff r229 p5dr port 5 data register ff core r230 cicr central interrupt control register 87 30 r231 flagr flag register 00 31 r232 rp0 pointer 0 register 00 33 r233 rp1 pointer 1 register 00 33 r234 ppr page pointer register 54 35 r235 moder mode register e0 35 r236 usphr user stack pointer high register xx 37 r237 usplr user stack pointer low register xx 37 r238 ssphr system stack pointer high reg. xx 37 r239 ssplr system stack pointer low reg. xx 37 0 int r242 eitr external interrupt trigger register 00 59 r243 eipr external interrupt pending reg. 00 60 r244 eimr external interrupt mask-bit reg. 00 60 r245 eiplr external interrupt priority level reg. ff 60 r246 eivr external interrupt vector register x6 61 r247 nicr nested interrupt control 00 61 wdt r248 wdthr watchdog timer high register ff 109 r249 wdtlr watchdog timer low register ff 109 r250 wdtpr watchdog timer prescaler reg. ff 109 r251 wdtcr watchdog timer control register 12 109 r252 wcr wait control register 7f 110 2 i/o port 3 r252 p3c0 port 3 configuration register 0 00 98 r253 p3c1 port 3 configuration register 1 00 r254 p3c2 port 3 configuration register 2 00 3 i/o port 4 r240 p4c0 port 4 configuration register 0 00 98 r241 p4c1 port 4 configuration register 1 00 r242 p4c2 port 4 configuration register 2 00 i/o port 5 r244 p5c0 port 5 configuration register 0 00 r245 p5c1 port 5 configuration register 1 00 r246 p5c2 port 5 configuration register 2 00 i/o port 6 r248 p6c0 port 6 configuration register 0 00 r249 p6c1 port 6 configuration register 1 00 r250 p6c2 port 6 configuration register 2 00 r251 p6dr port 6 data register ff
23/224 st92163 - general description 4 usb end points r240 ep0ra endpoint 0 register a (transmission) 00 143 r241 ep0rb endpoint 0 register b (reception) 00 r242 ep1ra endpoint 1 register a (transmission) 00 r243 ep1rb endpoint 1 register b (reception) 00 r244 ep2ra endpoint 2 register a (transmission) 00 r245 ep2rb endpoint 2 register b (reception) 00 r246 ep3ra endpoint 3 register a (transmission) 00 r247 ep3rb endpoint 3 register b (reception) 00 r248 ep4ra endpoint 4 register a (transmission) 00 r249 ep4rb endpoint 4 register b (reception) 00 r250 ep5ra endpoint 5 register a (transmission) 00 r251 ep5rb endpoint 5 register b (reception) 00 r252 ep6ra endpoint 6 register a (transmission) 00 r253 ep6rb endpoint 6 register b (reception) 00 r254 ep7ra endpoint 7 register a (transmission) 00 r255 ep7rb endpoint 7 register b (reception) 00 5 r240 ep8ra endpoint 8 register a (transmission) 00 r241 ep8rb endpoint 8 register b (reception) 00 r242 ep9ra endpoint 9 register a (transmission) 00 r243 ep9rb endpoint 9 register b (reception) 00 r244 ep10ra endpoint 10 register a (transmission) 00 r245 ep10rb endpoint 10 register b (reception) 00 r246 ep11ra endpoint 11 register a (transmission) 00 r247 ep11rb endpoint 11 register b (reception) 00 r248 ep12ra endpoint 12 register a (transmission) 00 r249 ep12rb endpoint 12 register b (reception) 00 r250 ep13ra endpoint 13 register a (transmission) 00 r251 ep13rb endpoint 13 register b (reception) 00 r252 ep14ra endpoint 14 register a (transmission) 00 r253 ep14rb endpoint 14 register b (reception) 00 r254 ep15ra endpoint 15 register a (transmission) 00 r255 ep15rb endpoint 15 register b (reception) 00 9 mft r240 dcpr dma counter pointer register xx 132 r241 dapr dma address pointer register xx 133 r242 t_ivr interrupt vector register xx 133 r243 idcr interrupt/dma control register c7 134 r248 iocr i/o connection register fc 134 page no. block reg. no. register name description reset value hex. doc. page
24/224 st92163 - general description 10 mft r240 reg0hr capture load register 0 high xx 125 r241 reg0lr capture load register 0 low xx 125 r242 reg1hr capture load register 1 high xx 125 r243 reg1lr capture load register 1 low xx 125 r244 cmp0hr compare 0 register high 00 125 r245 cmp0lr compare 0 register low 00 125 r246 cmp1hr compare 1 register high 00 125 r247 cmp1lr compare 1 register low 00 125 r248 tcr timer control register 0x 126 r249 tmr timer mode register 00 127 r250 t_icr external input control register 0x 128 r251 prsr prescaler register 00 128 r252 oacr output a control register xx 129 r253 obcr output b control register xx 130 r254 t_flagr flags register 00 31 r255 idmr interrupt/dma mask register 00 132 15 usb common r240 daddr0 device address register 0 00 143 r241 daddr1 device address register 1 00 r242 daddr2 device address register 2 00 r243 daddr3 device address register 3 00 r244 daddr4 device address register 4 00 r245 daddr5 device address register 5 00 r246 daddr6 device address register 6 00 r247 daddr7 device address register 7 00 r248 usbivr usb interrupt vector register xx 139 r249 usbistr usb interrupt status register 00 139 r250 usbimr usb interrupt mask register 00 140 r251 usbipr usb interrupt priority register xx 140 r252 usbctlr usb control register 17 141 r253 ctrinf ctr interrrupt flags xx 142 r254 fnrh frame number register high 0x 142 r255 fnrl frame number register low xx 142 page no. block reg. no. register name description reset value hex. doc. page
25/224 st92163 - general description 20 i2c r240 i2ccr i 2 c control register 00 186 r241 i2csr1 i 2 c status register 1 00 187 r242 i2csr2 i 2 c status register 2 00 189 r243 i2cccr i 2 c clock control register 00 190 r244 i2coar1 i 2 c own address register 1 00 190 r245 i2coar2 i 2 c own address register 2 00 191 r246 i2cdr i 2 c data register 00 191 r247 i2cadr i 2 c general call address a0 191 r248 i2cisr i 2 c interrupt status register xx 192 r249 i2civr i 2 c interrupt vector register xx 193 r250 i2crdap receiver dma source addr. pointer xx 193 r251 i2crdc receiver dma transaction counter xx 193 r252 i2ctdap transmitter dma source addr. pointer xx 194 r253 i2ctdc transmitter dma transaction counter xx 194 r254 i2ceccr i 2 c extended clock control register 00 194 r255 i2cimr i 2 c interrupt mask register x0 195 21 mmu r240 dpr0 data page register 0 00 42 r241 dpr1 data page register 1 01 42 r242 dpr2 data page register 2 02 42 r243 dpr3 data page register 3 83 42 r244 csr code segment register 00 43 r248 isr interrupt segment register x0 43 r249 dmasr dma segment register x0 43 extmi r245 emr1 external memory register 1 80 95 r246 emr2 external memory register 2 0f 96 24 sci r240 rdcpr receiver dma transaction counter pointer xx 165 r241 rdapr receiver dma source address pointer xx 165 r242 tdcpr transmitter dma transaction counter pointer xx 165 r243 tdapr transmitter dma destination address pointer xx 165 r244 s_ivr interrupt vector register xx 166 r245 acr address/data compare register xx 166 r246 imr interrupt mask register x0 167 r247 s_isr interrupt status register xx 43 r248 rxbr receive buffer register xx 169 r248 txbr transmitter buffer register xx 169 r249 idpr interrupt/dma priority register xx 170 r250 chcr character configuration register xx 171 r251 ccr clock configuration register 00 172 r252 brghr baud rate generator high reg. xx 173 r253 brglr baud rate generator low register xx 173 r254 sicr synchronous input control 03 173 r255 socr synchronous output control 01 174 page no. block reg. no. register name description reset value hex. doc. page
26/224 st92163 - general description note: xx denotes a byte with an undefined value, but some bits may have defined values. see register description for de- tails. 43 i/o port 8 r248 p8c0 port 8 configuration register 0 00 98 r249 p8c1 port 8 configuration register 1 00 r250 p8c2 port 8 configuration register 2 00 r251 p8dr port 8 data register ff i/o port 9 r252 p9c0 port 9 configuration register 0 00 r253 p9c1 port 9 configuration register 1 00 r254 p9c2 port 9 configuration register 2 00 r255 p9dr port 9 data register ff 55 rccu r240 clkctl clock control register 00 81 r242 clk_flag clock flag register 48, 28 or 08 82 r246 pllconf pll configuration register xx 83 59 wuimu r249 wuctrl wake-up control register 00 67 r250 wumrh wake-up mask register high 00 68 r251 wumrl wake-up mask register low 00 68 r252 wutrh wake-up trigger register high 00 69 r253 wutrl wake-up trigger register low 00 69 r254 wuprh wake-up pending register high 00 69 r255 wuprl wake-up pending register low 00 69 60 usb r244 devconf1 usb device configuration 1 0f 146 r245 devconf2 usb device configuration 2 00 146 r246 mirra mirror register a xx 147 r247 mirrb mirror register b xx 147 62 adc r240 addtr channel i data register xx 199 r241 adclr control logic register 00 199 r242 adint ad interrupt register 01 200 page no. block reg. no. register name description reset value hex. doc. page
27/224 st92163 - device architecture 2 device architecture 2.1 core architecture the st9+ core or central processing unit (cpu) features a highly optimised instruction set, capable of handling bit, byte (8-bit) and word (16-bit) data, as well as bcd and boolean formats; 14 address- ing modes are available. four independent buses are controlled by the core: a 16-bit memory bus, an 8-bit register data bus, an 8-bit register address bus and a 6-bit in- terrupt/dma bus which connects the interrupt and dma controllers in the on-chip peripherals with the core. this multiple bus architecture affords a high de- gree of pipelining and parallel operation, thus mak- ing the st9+ family devices highly efficient, both for numerical calculation, data handling and with regard to communication with on-chip peripheral resources. 2.2 memory spaces there are two separate memory spaces: the register file, which comprises 240 8-bit registers, arranged as 15 groups (group 0 to e), each containing sixteen 8-bit registers plus up to 64 pages of 16 registers mapped in group f, which hold data and control bits for the on-chip peripherals and i/os. a single linear memory space accommodating both program and data. all of the physically sep- arate memory areas, including the internal rom, internal ram and external memory are mapped in this common address space. the total ad- dressable memory space of 4 mbytes (limited by the size of on-chip memory and the number of external address pins) is arranged as 64 seg- ments of 64 kbytes. each segment is further subdivided into four pages of 16 kbytes, as illus- trated in figure 1. a memory management unit uses a set of pointer registers to address a 22-bit memory field using 16-bit address-based instruc- tions. 2.2.1 register file the register file consists of (see figure 2): 224 general purpose registers (group 0 to d, registers r0 to r223) 6 system registers in the system group (group e, registers r224 to r239) up to 64 pages, depending on device configura- tion, each containing up to 16 registers, mapped to group f (r240 to r255), see figure 3. figure 7. single program and data memory address space 3fffffh 3f0000h 3effffh 3e0000h 20ffffh 02ffffh 020000h 01ffffh 010000h 00ffffh 000000h 8 7 6 5 4 3 2 1 0 63 62 2 1 0 address 16k pages 64k segments up to 4 mbytes data code 255 254 253 252 251 250 249 248 247 9 10 11 21ffffh 210000h 133 134 135 33 reserved 132
28/224 st92163 - device architecture memory spaces (cont'd) figure 8. register groups figure 9. page pointer for group f mapping figure 10. addressing the register file f e d c b a 9 8 7 6 5 4 3 paged registers system registers 2 1 0 00 15 255 240 239 224 223 va00432 up to 64 pages general registers purpose 224 page 63 page 5 page 0 page pointer r255 r240 r224 r0 va00433 r234 register file system registers group d group b group c (1100) (0011) r192 r207 255 240 239 224 223 f e d c b a 9 8 7 6 5 4 3 2 1 0 15 vr000118 00 r195 r195 (r0c3h) paged registers
29/224 st92163 - device architecture memory spaces (cont'd) 2.2.2 register addressing register file registers, including group f paged registers (but excluding group d), may be ad- dressed explicitly by means of a decimal, hexa- decimal or binary address; thus r231, re7h and r11100111b represent the same register (see figure 4). group d registers can only be ad- dressed in working register mode. note that an upper case a r o is used to denote this direct addressing mode. working registers certain types of instruction require that registers be specified in the form a rx o, where x is in the range 0 to 15: these are known as working regis- ters. note that a lower case a r o is used to denote this in- direct addressing mode. two addressing schemes are available: a single group of 16 working registers, or two separately mapped groups, each consisting of 8 working reg- isters. these groups may be mapped starting at any 8 or 16 byte boundary in the register file by means of dedicated pointer registers. this tech- nique is described in more detail in section 1.3.3, and illustrated in figure 5 and in figure 6. system registers the 16 registers in group e (r224 to r239) are system registers and may be addressed using any of the register addressing modes. these registers are described in greater detail in section 1.3. paged registers up to 64 pages, each containing 16 registers, may be mapped to group f. these are addressed us- ing any register addressing mode, in conjunction with the page pointer register, r234, which is one of the system registers. this register selects the page to be mapped to group f and, once set, does not need to be changed if two or more regis- ters on the same page are to be addressed in suc- cession. therefore if the page pointer, r234, is set to 5, the instructions: spp #5 ld r242, r4 will load the contents of working register r4 into the third register of page 5 (r242). these paged registers hold data and control infor- mation relating to the on-chip peripherals, each peripheral always being associated with the same pages and registers to ensure code compatibility between st9+ devices. the number of these reg- isters therefore depends on the peripherals which are present in the specific st9+ family device. in other words, pages only exist if the relevant pe- ripheral is present. table 8. register file organization hex. address decimal address function register file group f0-ff 240-255 paged registers group f e0-ef 224-239 system registers group e d0-df 208-223 general purpose registers group d c0-cf 192-207 group c b0-bf 176-191 group b a0-af 160-175 group a 90-9f 144-159 group 9 80-8f 128-143 group 8 70-7f 112-127 group 7 60-6f 96-111 group 6 50-5f 80-95 group 5 40-4f 64-79 group 4 30-3f 48-63 group 3 20-2f 32-47 group 2 10-1f 16-31 group 1 00-0f 00-15 group 0
30/224 st92163 - device architecture 2.3 system registers the system registers are listed in table 2 system registers (group e). they are used to perform all the important system settings. their purpose is de- scribed in the following pages. refer to the chapter dealing with i/o for a description of the port[5:0] data registers. table 9. system registers (group e) 2.3.1 central interrupt control register please refer to the ointerrupto chapter for a de- tailed description of the st9 interrupt philosophy. central interrupt control register (cicr) r230 - read/write register group: e (system) reset value: 1000 0111 (87h) bit 7 = gcen : global counter enable . this bit is the global counter enable of the multi- function timers. the gcen bit is anded with the ce bit in the tcr register (only in devices featur- ing the mft multifunction timer) in order to enable the timers when both bits are set. this bit is set af- ter the reset cycle. note: if an mft is not included in the st9 device, then this bit has no effect. bit 6 = tlip : top level interrupt pending . this bit is set by hardware when a top level inter- rupt request is recognized. this bit can also be set by software to simulate a top level interrupt request. 0: no top level interrupt pending 1: top level interrupt pending bit 5 = tli : top level interrupt bit . 0: top level interrupt is acknowledged depending on the tlnm bit in the nicr register. 1: top level interrupt is acknowledged depending on the ien and tlnm bits in the nicr register (described in the interrupt chapter). bit 4 = ien : interrupt enable . this bit is cleared by interrupt acknowledgement, and set by interrupt return ( iret ). ien is modified implicitly by iret , ei and di instructions or by an interrupt acknowledge cycle. it can also be explic- itly written by the user, but only when no interrupt is pending. therefore, the user should execute a di instruction (or guarantee by other means that no interrupt request can arrive) before any write operation to the cicr register. 0: disable all interrupts except top level interrupt. 1: enable interrupts bit 3 = iam : interrupt arbitration mode . this bit is set and cleared by software to select the arbitration mode. 0: concurrent mode 1: nested mode. bit 2:0 = cpl[2:0] : current priority level . these three bits record the priority level of the rou- tine currently running (i.e. the current priority lev- el, cpl). the highest priority level is represented by 000, and the lowest by 111. the cpl bits can be set by hardware or software and provide the reference according to which subsequent inter- rupts are either left pending or are allowed to inter- rupt the current interrupt service routine. when the current interrupt is replaced by one of a higher pri- ority, the current priority value is automatically stored until required in the nicr register. r239 (efh) ssplr r238 (eeh) ssphr r237 (edh) usplr r236 (ech) usphr r235 (ebh) mode register r234 (eah) page pointer register r233 (e9h) register pointer 1 r232 (e8h) register pointer 0 r231 (e7h) flag register r230 (e6h) central int. cntl reg r229 (e5h) port5 data reg. r228 (e4h) port4 data reg. r227 (e3h) port3 data reg. r226 (e2h) port2 data reg. r225 (e1h) port1 data reg. r224 (e0h) port0 data reg. 70 gcen tlip tli ien iam cpl2 cpl1 cpl0
31/224 st92163 - device architecture system registers (cont'd) 2.3.2 flag register the flag register contains 8 flags which indicate the cpu status. during an interrupt, the flag regis- ter is automatically stored in the system stack area and recalled at the end of the interrupt service rou- tine, thus returning the cpu to its original status. this occurs for all interrupts and, when operating in nested mode, up to seven versions of the flag register may be stored. flag register (flagr) r231- read/write register group: e (system) reset value: 0000 0000 (00h ) bit 7 = c : carry flag . the carry flag is affected by: addition ( add, addw, adc, adcw ), subtraction ( sub, subw, sbc, sbcw ), compare ( cp, cpw ), shift right arithmetic ( sra, sraw ), shift left arithmetic ( sla, slaw ), swap nibbles ( swap ), rotate ( rrc, rrcw, rlc, rlcw, ror, rol ), decimal adjust ( da ), multiply and divide ( mul, div, divws ). when set, it generally indicates a carry out of the most significant bit position of the register being used as an accumulator (bit 7 for byte operations and bit 15 for word operations). the carry flag can be set by the set carry flag ( scf ) instruction, cleared by the reset carry flag ( rcf ) instruction, and complemented by the com- plement carry flag ( ccf ) instruction. bit 6 = z: zero flag . the zero flag is affected by: addition ( add, addw, adc, adcw ), subtraction ( sub, subw, sbc, sbcw ), compare ( cp, cpw ), shift right arithmetic ( sra, sraw ), shift left arithmetic ( sla, slaw ), swap nibbles ( swap ), rotate (rrc , rrcw, rlc, rlcw, ror, rol) , decimal adjust ( da ), multiply and divide ( mul, div, divws ), logical ( and, andw, or, orw, xor, xorw, cpl ), increment and decrement ( inc, incw, dec, decw ), test ( tm, tmw, tcm, tcmw, btset ). in most cases, the zero flag is set when the contents of the register being used as an accumulator be- come zero, following one of the above operations. bit 5 = s : sign flag . the sign flag is affected by the same instructions as the zero flag. the sign flag is set when bit 7 (for a byte opera- tion) or bit 15 (for a word operation) of the register used as an accumulator is one. bit 4 = v : overflow flag . the overflow flag is affected by the same instruc- tions as the zero and sign flags. when set, the overflow flag indicates that a two's- complement number, in a result register, is in er- ror, since it has exceeded the largest (or is less than the smallest), number that can be represent- ed in two's-complement notation. bit 3 = da : decimal adjust flag . the da flag is used for bcd arithmetic. since the algorithm for correcting bcd operations is differ- ent for addition and subtraction, this flag is used to specify which type of instruction was executed last, so that the subsequent decimal adjust ( da ) operation can perform its function correctly. the da flag cannot normally be used as a test condi- tion by the programmer. bit 2 = h : half carry flag. the h flag indicates a carry out of (or a borrow in- to) bit 3, as the result of adding or subtracting two 8-bit bytes, each representing two bcd digits. the h flag is used by the decimal adjust ( da ) instruc- tion to convert the binary result of a previous addi- tion or subtraction into the correct bcd result. like the da flag, this flag is not normally accessed by the user. bit 1 = reserved bit (must be 0). bit 0 = dp : data/program memory flag . this bit indicates the memory area addressed. its value is affected by the set data memory ( sdm ) and set program memory ( spm ) instructions. re- fer to the memory management unit for further de- tails. 70 c z s v da h - dp
32/224 st92163 - device architecture system registers (cont'd) if the bit is set, data is accessed using the data pointers (dprs registers), otherwise it is pointed to by the code pointer (csr register); therefore, the user initialization routine must include a sdm instruction. note that code is always pointed to by the code pointer (csr). note: in the st9+, the dp flag is only for compat- ibility with software developed for the first genera- tion of st9 devices. with the single memory ad- dressing space, its use is now redundant. it must be kept to 1 with a sdm instruction at the beginning of the program to ensure a normal use of the differ- ent memory pointers. 2.3.3 register pointing techniques two registers within the system register group, are used as pointers to the working registers. reg- ister pointer 0 (r232) may be used on its own as a single pointer to a 16-register working space, or in conjunction with register pointer 1 (r233), to point to two separate 8-register spaces. for the purpose of register pointing, the 16 register groups of the register file are subdivided into 32 8- register blocks. the values specified with the set register pointer instructions refer to the blocks to be pointed to in twin 8-register mode, or to the low- er 8-register block location in single 16-register mode. the set register pointer instructions srp , srp0 and srp1 automatically inform the cpu whether the register file is to operate in single 16-register mode or in twin 8-register mode. the srp instruc- tion selects the single 16-register group mode and specifies the location of the lower 8-register block, while the srp0 and srp1 instructions automatical- ly select the twin 8-register group mode and spec- ify the locations of each 8-register block. there is no limitation on the order or position of these register groups, other than that they must start on an 8-register boundary in twin 8-register mode, or on a 16-register boundary in single 16- register mode. the block number should always be an even number in single 16-register mode. the 16-regis- ter group will always start at the block whose number is the nearest even number equal to or lower than the block number specified in the srp instruction. avoid using odd block numbers, since this can be confusing if twin mode is subsequently selected. thus: srp #3 will be interpreted as srp #2 and will al- low using r16 ..r31 as r0 .. r15. in single 16-register mode, the working registers are referred to as r0 to r15 . in twin 8-register mode, registers r0 to r7 are in the block pointed to by rp0 (by means of the srp0 instruction), while registers r8 to r15 are in the block pointed to by rp1 (by means of the srp1 instruction). caution : group d registers can only be accessed as working registers using the register pointers, or by means of the stack pointers. they cannot be addressed explicitly in the form a rxxx o.
33/224 st92163 - device architecture system registers (cont'd) pointer 0 register (rp0) r232 - read/write register group: e (system) reset value: xxxx xx00 (xxh) bit 7:3 = rg[4:0] : register group number. these bits contain the number (in the range 0 to 31) of the register block specified in the srp0 or srp instructions. in single 16-register mode the number indicates the lower of the two 8-register blocks to which the 16 working registers are to be mapped, while in twin 8-register mode it indicates the 8-register block to which r0 to r7 are to be mapped. bit 2 = rps : register pointer selector . this bit is set by the instructions srp0 and srp1 to indicate that the twin register pointing mode is se- lected. the bit is reset by the srp instruction to in- dicate that the single register pointing mode is se- lected. 0: single register pointing mode 1: twin register pointing mode bit 1:0: reserved. forced by hardware to zero. pointer 1 register (rp1) r233 - read/write register group: e (system) reset value: xxxx xx00 (xxh) this register is only used in the twin register point- ing mode. when using the single register pointing mode, or when using only one of the twin register groups, the rp1 register must be considered as reserved and may not be used as a general purpose register. bit 7:3 = rg[4:0]: register group number. these bits contain the number (in the range 0 to 31) of the 8-register block specified in the srp1 instruc- tion, to which r8 to r15 are to be mapped. bit 2 = rps : register pointer selector . this bit is set by the srp0 and srp1 instructions to indicate that the twin register pointing mode is se- lected. the bit is reset by the srp instruction to in- dicate that the single register pointing mode is se- lected. 0: single register pointing mode 1: twin register pointing mode bit 1:0: reserved. forced by hardware to zero. 70 rg4 rg3 rg2 rg1 rg0 rps 0 0 70 rg4 rg3 rg2 rg1 rg0 rps 0 0
34/224 st92163 - device architecture system registers (cont'd) figure 11. pointing to a single group of 16 registers figure 12. pointing to two groups of 8 registers 31 30 29 28 27 26 25 9 8 7 6 5 4 3 2 1 0 f e d 4 3 2 1 0 block number register group regist er file register pointer 0 srp #2 set by: instruction points to: group 1 addressed by block 2 r15 r0 31 30 29 28 27 26 25 9 8 7 6 5 4 3 2 1 0 f e d 4 3 2 1 0 block number regist er group register file register pointe r 0 srp0 #2 set by: instructions point to: group 1 addressed by block 2 & regist er pointe r 1 srp1 #7 & group 3 addressed by block 7 r7 r0 r15 r8
35/224 st92163 - device architecture system registers (cont'd) 2.3.4 paged registers up to 64 pages, each containing 16 registers, may be mapped to group f. these paged registers hold data and control information relating to the on-chip peripherals, each peripheral always being associated with the same pages and registers to ensure code compatibility between st9+ devices. the number of these registers depends on the pe- ripherals present in the specific st9 device. in oth- er words, pages only exist if the relevant peripher- al is present. the paged registers are addressed using the nor- mal register addressing modes, in conjunction with the page pointer register, r234, which is one of the system registers. this register selects the page to be mapped to group f and, once set, does not need to be changed if two or more regis- ters on the same page are to be addressed in suc- cession. thus the instructions: spp #5 ld r242, r4 will load the contents of working register r4 into the third register of page 5 (r242). warning: during an interrupt, the ppr register is not saved automatically in the stack. if needed, it should be saved/restored by the user within the in- terrupt routine. page pointer register (ppr) r234 - read/write register group: e (system) reset value: xxxx xx00 (xxh ) bit 7:2 = pp[5:0] : page pointer . these bits contain the number (in the range 0 to 63) of the page specified in the spp instruction. once the page pointer has been set, there is no need to refresh it unless a different page is re- quired. bit 1:0: reserved. forced by hardware to 0. 2.3.5 mode register the mode register allows control of the following operating parameters: selection of internal or external system and user stack areas, management of the clock frequency, enabling of bus request and wait signals when interfacing to external memory. mode register (moder) r235 - read/write register group: e (system) reset value: 1110 0000 (e0h) bit 7 = ssp : system stack pointer . this bit selects an internal or external system stack area. 0: external system stack area, in memory space. 1: internal system stack area, in the register file (reset state). bit 6 = usp : user stack pointer . this bit selects an internal or external user stack area. 0: external user stack area, in memory space. 1: internal user stack area, in the register file (re- set state). bit 5 = div2 : oscin clock divided by 2 . this bit controls the divide-by-2 circuit operating on oscin. 0: clock divided by 1 1: clock divided by 2 bit 4:2 = prs[2:0] : cpuclk prescaler . these bits load the prescaler division factor for the internal clock (intclk). the prescaler factor se- lects the internal clock frequency, which can be di- vided by a factor from 1 to 8. refer to the reset and clock control chapter for further information. bit 1 = brqen : bus request enable . 0: external memory bus request disabled 1: external memory bus request enabled on the breq pin (where available). bit 0 = himp : high impedance enable . when any of ports 0, 1, 2 or 6 depending on de- vice configuration, are programmed as address and data lines to interface external memory, these lines and the memory interface control lines (as, 70 pp5 pp4 pp3 pp2 pp1 pp0 0 0 70 ssp usp div2 prs2 prs1 prs0 brqen himp
36/224 st92163 - device architecture system registers (cont'd) ds, r/w) can be forced into the high impedance state by setting the himp bit. when this bit is reset, it has no effect. setting the himp bit is recommended for noise re- duction when only internal memory is used. if port 1 and/or 2 are declared as an address and as an i/o port (for example: p10... p14 = address, and p15... p17 = i/o), the himp bit has no effect on the i/o lines. 2.3.6 stack pointers two separate, double-register stack pointers are available: the system stack pointer and the user stack pointer, both of which can address registers or memory. the stack pointers point to the abottomo of the stacks which are filled using the push commands and emptied using the pop commands. the stack pointer is automatically pre-decremented when data is apushedo in and post-incremented when data is apoppedo out. the push and pop commands used to manage the system stack may be addressed to the user stack by adding the suffix a uo . to use a stack in- struction for a word, the suffix a wo is added. these suffixes may be combined. when bytes (or words) are apoppedo out from a stack, the contents of the stack locations are un- changed until fresh data is loaded. thus, when data is apoppedo from a stack area, the stack con- tents remain unchanged. note: instructions such as: pushuw rr236 or pushw rr238, as well as the corresponding pop instructions (where r236 & r237, and r238 & r239 are themselves the user and system stack pointers respectively), must not be used, since the pointer values are themselves automatically changed by the push or pop instruction, thus cor- rupting their value. system stack the system stack is used for the temporary stor- age of system and/or control data, such as the flag register and the program counter. the following automatically push data onto the system stack: interrupts when entering an interrupt, the pc and the flag register are pushed onto the system stack. if the encsr bit in the emr2 register is set, then the code segment register is also pushed onto the system stack. subroutine calls when a call instruction is executed, only the pc is pushed onto stack, whereas when a calls in- struction (call segment) is executed, both the pc and the code segment register are pushed onto the system stack. link instruction the link or linku instructions create a c lan- guage stack frame of user-defined length in the system or user stack. all of the above conditions are associated with their counterparts, such as return instructions, which pop the stored data items off the stack. user stack the user stack provides a totally user-controlled stacking area. the user stack pointer consists of two registers, r236 and r237, which are both used for address- ing a stack in memory. when stacking in the reg- ister file, the user stack pointer high register, r236, becomes redundant but must be consid- ered as reserved. stack pointers both system and user stacks are pointed to by double-byte stack pointers. stacks may be set up in ram or in the register file. only the lower byte will be required if the stack is in the register file. the upper byte must then be considered as re- served and must not be used as a general purpose register. the stack pointer registers are located in the sys- tem group of the register file, this is illustrated in table 2 system registers (group e). stack location care is necessary when managing stacks as there is no limit to stack sizes apart from the bottom of any address space in which the stack is placed. consequently programmers are advised to use a stack pointer value as high as possible, particular- ly when using the register file as a stacking area. group d is a good location for a stack in the reg- ister file, since it is the highest available area. the stacks may be located anywhere in the first 14 groups of the register file (internal stacks) or in ram (external stacks). note . stacks must not be located in the paged register group or in the system register group.
37/224 st92163 - device architecture system registers (cont'd) user stack pointer high register (usphr) r236 - read/write register group: e (system) reset value: undefined user stack pointer low register (usplr) r237 - read/write register group: e (system) reset value: undefined figure 13. internal stack mode system stack pointer high register (ssphr) r238 - read/write register group: e (system) reset value: undefined system stack pointer low register (ssplr) r239 - read/write register group: e (system) reset value: undefined figure 14. external stack mode 70 usp15 usp14 usp13 usp12 usp11 usp10 usp9 usp8 70 usp7 usp6 usp5 usp4 usp3 usp2 usp1 usp0 f e d 4 3 2 1 0 regist er file stack pointer (low) points to: stack 70 ssp15 ssp14 ssp13 ssp12 ssp11 ssp10 ssp9 ssp8 70 ssp7 ssp6 ssp5 ssp4 ssp3 ssp2 ssp1 ssp0 f e d 4 3 2 1 0 register file stack pointer (low) point to: stack memory stack pointer (high) &
38/224 st92163 - device architecture 2.4 memory organization code and data are accessed within the same line- ar address space. all of the physically separate memory areas, including the internal rom, inter- nal ram and external memory are mapped in a common address space. the st9+ provides a total addressable memory space of 4 mbytes. this address space is ar- ranged as 64 segments of 64 kbytes; each seg- ment is again subdivided into four 16 kbyte pages. the mapping of the various memory areas (inter- nal ram or rom, external memory) differs from device to device. each 64-kbyte physical memory segment is mapped either internally or externally; if the memory is internal and smaller than 64 kbytes, the remaining locations in the 64-kbyte segment are not used (reserved). refer to the register and memory map chapter for more details on the memory map.
39/224 st92163 - device architecture 2.5 memory management unit the cpu core includes a memory management unit (mmu) which must be programmed to per- form memory accesses (even if external memory is not used). the mmu is controlled by 7 registers and 2 bits (encsr and dprrem) present in emr2, which may be written and read by the user program. these registers are mapped within group f, page 21 of the register file. the 7 registers may be sub-divided into 2 main groups: a first group of four 8-bit registers (dpr[3:0]), and a second group of three 6-bit registers (csr, isr, and dmasr). the first group is used to extend the address during data memory access (dpr[3:0]). the second is used to manage program and data memory ac- cesses during code execution (csr), interrupts service routines (isr or csr), and dma trans- fers (dmasr or isr). figure 15. page 21 registers dmasr isr emr2 emr1 csr dpr3 dpr2 dpr1 dpr0 r255 r254 r253 r252 r251 r250 r249 r248 r247 r246 r245 r244 r243 r242 r241 r240 ffh feh fdh fch fbh fah f9h f8h f7h f6h f5h f4h f3h f2h f1h f0h mmu em page 21 mmu mmu bit dprrem=0 ssplr ssphr usplr usphr moder ppr rp1 rp0 flagr cicr p5dr p4dr p3dr p2dr p1dr p0dr dmasr isr emr2 emr1 csr dpr3 dpr2 1 dpr0 bit dprrem=1 ssplr ssphr usplr usphr moder ppr rp1 rp0 flagr cicr p5dr p4dr p3dr p2dr p1dr p0dr dmasr isr emr2 emr1 csr dpr3 dpr2 dpr1 dpr0 relocation of p[3:0] and dpr[3:0] registers (default setting)
40/224 st92163 - device architecture 2.6 address space extension to manage 4 mbytes of addressing space it is necessary to have 22 address bits. the mmu adds 6 bits to the usual 16-bit address, thus trans- lating a 16-bit virtual address into a 22-bit physical address. there are 2 different ways to do this de- pending on the memory involved and on the oper- ation being performed. 2.6.1 addressing 16-kbyte pages this extension mode is implicitly used to address data memory space if no dma is being performed. the data memory space is divided into 4 pages of 16 kbytes. each one of the four 8-bit registers (dpr[3:0], data page registers) selects a differ- ent 16-kbyte page. the dpr registers allow ac- cess to the entire memory space which contains 256 pages of 16 kbytes. data paging is performed by extending the 14 lsb of the 16-bit address with the contents of a dpr register. the two msbs of the 16-bit address are interpreted as the identification number of the dpr register to be used. therefore, the dpr registers are involved in the following virtual address rang- es: dpr0: from 0000h to 3fffh; dpr1: from 4000h to 7fffh; dpr2: from 8000h to bfffh; dpr3: from c000h to ffffh. the contents of the selected dpr register specify one of the 256 possible data memory pages. this 8-bit data page number, in addition to the remain- ing 14-bit page offset address forms the physical 22-bit address (see figure 10). a dpr register cannot be modified via an address- ing mode that uses the same dpr register. for in- stance, the instruction apopw dpr0o is legal only if the stack is kept either in the register file or in a memory location above 8000h, where dpr2 and dpr3 are used. otherwise, since dpr0 and dpr1 are modified by the instruction, unpredicta- ble behaviour could result. figure 16. addressing via dpr[3:0] dpr0 dpr1 dpr2 dpr3 00 01 10 11 16-bit virtual address 22-bit physical address 8 bits mmu registers 2 m sb 14 lsb
41/224 st92163 - device architecture address space extension (cont'd) 2.6.2 addressing 64-kbyte segments this extension mode is used to address data memory space during a dma and program mem- ory space during any code execution (normal code and interrupt routines). three registers are used: csr, isr, and dmasr. the 6-bit contents of one of the registers csr, isr, or dmasr define one out of 64 memory seg- ments of 64 kbytes within the 4 mbytes address space. the register contents represent the 6 msbs of the memory address, whereas the 16 lsbs of the address (intra-segment address) are given by the virtual 16-bit address (see figure 11). 2.7 mmu registers the mmu uses 7 registers mapped into group f, page 21 of the register file and 2 bits of the emr2 register. most of these registers do not have a default value after reset. 2.7.1 dpr[3:0]: data page registers the dpr[3:0] registers allow access to the entire 4 mbyte memory space composed of 256 pages of 16 kbytes. 2.7.1.1 data page register relocation if these registers are to be used frequently, they may be relocated in register group e, by program- ming bit 5 of the emr2-r246 register in page 21. if this bit is set, the dpr[3:0] registers are located at r224-227 in place of the port 0-3 data registers, which are re-mapped to the default dpr's loca- tions: r240-243 page 21. data page register relocation is illustrated in fig- ure 9. figure 17. addressing via csr, isr, and dmasr fetching program data memory fetching interrupt instruction accessed in dma instruction or dma access to program memory 16-bit virtual address 22-bit physical address 6 bits mmu registers csr isr dmasr 123 1 2 3
42/224 st92163 - device architecture mmu registers (cont'd) data page register 0 (dpr0) r240 - read/write register page: 21 reset value: undefined this register is relocated to r224 if emr2.5 is set. bit 7:0 = dpr0_[7:0] : these bits define the 16- kbyte data memory page number. they are used as the most significant address bits (a21-14) to ex- tend the address during a data memory access. the dpr0 register is used when addressing the virtual address range 0000h-3fffh. data page register 1 (dpr1) r241 - read/write register page: 21 reset value: undefined this register is relocated to r225 if emr2.5 is set. bit 7:0 = dpr1_[7:0] : these bits define the 16- kbyte data memory page number. they are used as the most significant address bits (a21-14) to ex- tend the address during a data memory access. the dpr1 register is used when addressing the virtual address range 4000h-7fffh. data page register 2 (dpr2) r242 - read/write register page: 21 reset value: undefined this register is relocated to r226 if emr2.5 is set. bit 7:0 = dpr2_[7:0] : these bits define the 16- kbyte data memory page. they are used as the most significant address bits (a21-14) to extend the address during a data memory access. the dpr2 register is involved when the virtual address is in the range 8000h-bfffh. data page register 3 (dpr3) r243 - read/write register page: 21 reset value: undefined this register is relocated to r227 if emr2.5 is set. bit 7:0 = dpr3_[7:0] : these bits define the 16- kbyte data memory page. they are used as the most significant address bits (a21-14) to extend the address during a data memory access. the dpr3 register is involved when the virtual address is in the range c000h-ffffh. 70 dpr0_7 dpr0_6 dpr0_5 dpr0_4 dpr0_3 dpr0_2 dpr0_1 dpr0_0 70 dpr1_7 dpr1_6 dpr1_5 dpr1_4 dpr1_3 dpr1_2 dpr1_1 dpr1_0 70 dpr2_7 dpr2_6 dpr2_5 dpr2_4 dpr2_3 dpr2_2 dpr2_1 dpr2_0 70 dpr3_7 dpr3_6 dpr3_5 dpr3_4 dpr3_3 dpr3_2 dpr3_1 dpr3_0
43/224 st92163 - device architecture mmu registers (cont'd) 2.7.2 csr: code segment register this register selects the 64-kbyte code segment being used at run-time to access instructions. it can also be used to access data if the spm instruc- tion has been executed (or ldpp, ldpd, lddp ). only the 6 lsbs of the csr register are imple- mented, and bits 6 and 7 are reserved. the csr register allows access to the entire memory space, divided into 64 segments of 64 kbytes. to generate the 22-bit program memory address, the contents of the csr register is directly used as the 6 msbs, and the 16-bit virtual address as the 16 lsbs. note: the csr register should only be read and not written for data operations (there are some ex- ceptions which are documented in the following paragraph). it is, however, modified either directly by means of the jps and calls instructions, or indirectly via the stack, by means of the rets in- struction. code segment register (csr) r244 - read/write register page: 21 reset value: 0000 0000 (00h) bit 7:6 = reserved, keep in reset state. bit 5:0 = csr_[5:0] : these bits define the 64- kbyte memory segment (among 64) which con- tains the code being executed. these bits are used as the most significant address bits (a21-16). 2.7.3 isr: interrupt segment register interrupt segment register (isr) r248 - read/write register page: 21 reset value: undefined isr and encsr bit (emr2 register) are also de- scribed in the chapter relating to interrupts, please refer to this description for further details. bit 7:6 = reserved, keep in reset state. bit 5:0 = isr_[5:0] : these bits define the 64-kbyte memory segment (among 64) which contains the interrupt vector table and the code for interrupt service routines and dma transfers (when the ps bit of the dapr register is reset). these bits are used as the most significant address bits (a21-16). the isr is used to extend the address space in two cases: whenever an interrupt occurs: isr points to the 64-kbyte memory segment containing the inter- rupt vector table and the interrupt service routine code. see also the interrupts chapter. during dma transactions between the peripheral and memory when the ps bit of the dapr regis- ter is reset : isr points to the 64 k-byte memory segment that will be involved in the dma trans- action. 2.7.4 dmasr: dma segment register dma segment register (dmasr) r249 - read/write register page: 21 reset value: undefined bit 7:6 = reserved, keep in reset state. bit 5:0 = dmasr_[5:0] : these bits define the 64- kbyte memory segment (among 64) used when a dma transaction is performed between the periph- eral's data register and memory, with the ps bit of the dapr register set. these bits are used as the most significant address bits (a21-16). if the ps bit is reset, the isr register is used to extend the ad- dress. 70 00 csr_5 csr_4 csr_3 csr_2 csr_1 csr_0 70 0 0 isr_5 isr_4 isr_3 isr_2 isr_1 isr_0 70 00 dma sr_5 dma sr_4 dma sr_3 dma sr_2 dma sr_1 dma sr_0
44/224 st92163 - device architecture mmu registers (cont'd) figure 18. memory addressing scheme (example) 3fffffh 294000h 240000h 23ffffh 20c000h 200000h 1fffffh 040000h 03ffffh 030000h 020000h 010000h 00c000h 000000h dmasr isr csr dpr3 dpr2 dpr1 dpr0 4m bytes 16k 16k 16k 64k 64k 64k 16k
45/224 st92163 - device architecture 2.8 mmu usage 2.8.1 normal program execution program memory is organized as a set of 64- kbyte segments. the program can span as many segments as needed, but a procedure cannot stretch across segment boundaries. jps , calls and rets instructions, which automatically modify the csr, must be used to jump across segment boundaries. writing to the csr is forbidden during normal program execution because it is not syn- chronized with the opcode fetch. this could result in fetching the first byte of an instruction from one memory segment and the second byte from anoth- er. writing to the csr is allowed when it is not be- ing used, i.e during an interrupt service routine if encsr is reset. note that a routine must always be called in the same way, i.e. either always with call or always with calls , depending on whether the routine ends with ret or rets . this means that if the rou- tine is written without prior knowledge of the loca- tion of other routines which call it, and all the pro- gram code does not fit into a single 64-kbyte seg- ment, then calls / rets should be used. in typical microcontroller applications, less than 64 kbytes of ram are used, so the four data space pages are normally sufficient, and no change of dpr[3:0] is needed during program execution. it may be useful however to map part of the rom into the data space if it contains strings, tables, bit maps, etc. if there is to be frequent use of paging, the user can set bit 5 (dprrem) in register r246 (emr2) of page 21. this swaps the location of registers dpr[3:0] with that of the data registers of ports 0- 3. in this way, dpr registers can be accessed without the need to save/set/restore the page pointer register. port registers are therefore moved to page 21. applications that require a lot of paging typically use more than 64 kbytes of exter- nal memory, and as ports 0, 1 and 2 are required to address it, their data registers are unused. 2.8.2 interrupts the isr register has been created so that the in- terrupt routines may be found by means of the same vector table even after a segment jump/call. when an interrupt occurs, the cpu behaves in one of 2 ways, depending on the value of the enc- sr bit in the emr2 register (r246 on page 21). if this bit is reset (default condition), the cpu works in original st9 compatibility mode. for the duration of the interrupt service routine, the isr is used instead of the csr, and the interrupt stack frame is kept exactly as in the original st9 (only the pc and flags are pushed). this avoids the need to save the csr on the stack in the case of an interrupt, ensuring a fast interrupt response time. the drawback is that it is not possible for an interrupt service routine to perform segment calls / jps : these instructions would update the csr, which, in this case, is not used (isr is used instead). the code size of all interrupt service rou- tines is thus limited to 64 kbytes. if, instead, bit 6 of the emr2 register is set, the isr is used only to point to the interrupt vector ta- ble and to initialize the csr at the beginning of the interrupt service routine: the old csr is pushed onto the stack together with the pc and the flags, and then the csr is loaded with the isr. in this case, an iret will also restore the csr from the stack. this approach lets interrupt service routines access the whole 4-mbyte address space. the drawback is that the interrupt response time is slightly increased, because of the need to also save the csr on the stack. compatibility with the original st9 is also lost in this case, because the interrupt stack frame is different; this difference, however, would not be noticeable for a vast major- ity of programs. data memory mapping is independent of the value of bit 6 of the emr2 register, and remains the same as for normal code execution: the stack is the same as that used by the main program, as in the st9. if the interrupt service routine needs to access additional data memory, it must save one (or more) of the dprs, load it with the needed memory page and restore it before completion. 2.8.3 dma depending on the ps bit in the dapr register (see dma chapter) dma uses either the isr or the dmasr for memory accesses: this guarantees that a dma will always find its memory seg- ment(s), no matter what segment changes the ap- plication has performed. unlike interrupts, dma transactions cannot save/restore paging registers, so a dedicated segment register (dmasr) has been created. having only one register of this kind means that all dma accesses should be pro- grammed in one of the two following segments: the one pointed to by the isr (when the ps bit of the dapr register is reset), and the one refer- enced by the dmasr (when the ps bit is set).
46/224 st92163 - interrupts 3 interrupts 3.1 introduction the st9 responds to peripheral and external events through its interrupt channels. current pro- gram execution can be suspended to allow the st9 to execute a specific response routine when such an event occurs, providing that interrupts have been enabled, and according to a priority mechanism. if an event generates a valid interrupt request, the current program status is saved and control passes to the appropriate interrupt service routine. the st9 cpu can receive requests from the fol- lowing sources: on-chip peripherals external pins top-level pseudo-non-maskable interrupt according to the on-chip peripheral features, an event occurrence can generate an interrupt re- quest which depends on the selected mode. up to eight external interrupt channels, with pro- grammable input trigger edge, are available. in ad- dition, a dedicated interrupt channel, set to the top-level priority, can be devoted either to the ex- ternal nmi pin (where available) to provide a non- maskable interrupt, or to the timer/watchdog. in- terrupt service routines are addressed through a vector table mapped in memory. figure 19. interrupt response normal program flow interrupt service routine iret instruction interrupt vr001833 clear pending bit
47/224 st92163 - interrupts interrupts (cont'd) 3.2 interrupt vectoring the st9 implements an interrupt vectoring struc- ture which allows the on-chip peripheral to identify the location of the first instruction of the interrupt service routine automatically. when an interrupt request is acknowledged, the peripheral interrupt module provides, through its interrupt vector register (ivr), a vector to point into the vector table of locations containing the start addresses of the interrupt service routines (defined by the programmer). each peripheral has a specific ivr mapped within its register file pages. the interrupt vector table, containing the address- es of the interrupt service routines, is located in the first 256 locations of memory pointed to by the isr register, thus allowing 8-bit vector addressing. for a description of the isr register refer to the chapter describing the mmu. the user power on reset vector is stored in the first two physical bytes in memory, 000000h and 000001h. the top level interrupt vector is located at ad- dresses 0004h and 0005h in the segment pointed to by the interrupt segment register (isr). with one interrupt vector register, it is possible to address several interrupt service routines; in fact, peripherals can share the same interrupt vector register among several interrupt channels. the most significant bits of the vector are user pro- grammable to define the base vector address with- in the vector table, the least significant bits are controlled by the interrupt module, in hardware, to select the appropriate vector. note : the first 256 locations of the memory seg- ment pointed to by isr can contain program code. 3.2.1 divide by zero trap the divide by zero trap vector is located at ad- dresses 0002h and 0003h of each code segment; it should be noted that for each code segment a divide by zero service routine is required. warning . although the divide by zero trap oper- ates as an interrupt, the flag register is not pushed onto the system stack automatically. as a result it must be regarded as a subroutine, and the service routine must end with the ret instruction (not iret ). figure 20. interrupt vector table user isr program memory power-on reset divide-b y-zero top level int. lo lo lo hi hi hi 000000h user main program user top level isr user divide-by -zero isr 0000ffh vector table isr addres s even odd int. vector register lo hi registe r file r240 r239 f page registe rs 000002h 000004h
48/224 st92163 - interrupts interrupts (cont'd) 3.2.2 segment paging during interrupt routines the encsr bit in the emr2 register can be used to select between original st9 backward compati- bility mode and st9+ interrupt management mode. st9 backward compatibility mode (encsr = 0) if encsr is reset, the cpu works in original st9 compatibility mode. for the duration of the inter- rupt service routine, isr is used instead of csr, and the interrupt stack frame is identical to that of the original st9: only the pc and flags are pushed. this avoids saving the csr on the stack in the event of an interrupt, thus ensuring a faster inter- rupt response time. it is not possible for an interrupt service routine to perform inter-segment calls or jumps: these in- structions would update the csr, which, in this case, is not used (isr is used instead). the code segment size for all interrupt service routines is thus limited to 64k bytes. st9+ mode (encsr = 1) if encsr is set, isr is only used to point to the in- terrupt vector table and to initialize the csr at the beginning of the interrupt service routine: the old csr is pushed onto the stack together with the pc and flags, and csr is then loaded with the con- tents of isr. in this case, iret will also restore csr from the stack. this approach allows interrupt service rou- tines to access the entire 4 mbytes of address space. the drawback is that the interrupt response time is slightly increased, because of the need to also save csr on the stack. full compatibility with the original st9 is lost in this case, because the interrupt stack frame is differ- ent. 3.3 interrupt priority levels the st9 supports a fully programmable interrupt priority structure. nine priority levels are available to define the channel priority relationships: the on-chip peripheral channels and the eight external interrupt sources can be programmed within eight priority levels. each channel has a 3- bit field, prl (priority level), that defines its pri- ority level in the range from 0 (highest priority) to 7 (lowest priority). the 9th level (top level priority) is reserved for the timer/watchdog or the external pseudo non-maskable interrupt. an interrupt service routine at this level cannot be interrupted in any arbitration mode. its mask can be both maskable (tli) or non-maskable (tlnm). 3.4 priority level arbitration the 3 bits of cpl (current priority level) in the central interrupt control register contain the pri- ority of the currently running program (cpu priori- ty). cpl is set to 7 (lowest priority) upon reset and can be modified during program execution either by software or automatically by hardware accord- ing to the selected arbitration mode. during every instruction, an arbitration phase takes place, during which, for every channel capa- ble of generating an interrupt, each priority level is compared to all the other requests (interrupts or dma). if the highest priority request is an interrupt, its prl value must be strictly lower (that is, higher pri- ority) than the cpl value stored in the cicr regis- ter (r230) in order to be acknowledged. the top level interrupt overrides every other priority. 3.4.1 priority level 7 (lowest) interrupt requests at prl level 7 cannot be ac- knowledged, as this prl value (the lowest possi- ble priority) cannot be strictly lower than the cpl value. this can be of use in a fully polled interrupt environment. 3.4.2 maximum depth of nesting no more than 8 routines can be nested. if an inter- rupt routine at level n is being serviced, no other interrupts located at level n can interrupt it. this guarantees a maximum number of 8 nested levels including the top level interrupt request. 3.4.3 simultaneous interrupts if two or more requests occur at the same time and at the same priority level, an on-chip daisy chain, specific to every st9 version, selects the channel encsr bit 0 1 mode st9 compatible st9+ pushed/popp ed registers pc, flagr pc, flagr, csr max. code size for interrupt service routine 64kb within 1 segment <4 mb across segments
49/224 st92163 - interrupts with the highest position in the chain, as shown in table 10. table 10. daisy chain priority 3.4.4 dynamic priority level modification the main program and routines can be specifically prioritized. since the cpl is represented by 3 bits in a read/write register, it is possible to modify dy- namically the current priority value during program execution. this means that a critical section can have a higher priority with respect to other inter- rupt requests. furthermore it is possible to priori- tize even the main program execution by modify- ing the cpl during its execution. see figure 21 figure 21. example of dynamic priority level modification in nested mode 3.5 arbitration modes the st9 provides two interrupt arbitration modes: concurrent mode and nested mode. concurrent mode is the standard interrupt arbitration mode. nested mode improves the effective interrupt re- sponse time when service routine nesting is re- quired, depending on the request priority levels. the iam control bit in the cicr register selects concurrent arbitration mode or nested arbitration mode. 3.5.1 concurrent mode this mode is selected when the iam bit is cleared (reset condition). the arbitration phase, performed during every instruction, selects the request with the highest priority level. the cpl value is not modified in this mode. start of interrupt routine the interrupt cycle performs the following steps: all maskable interrupt requests are disabled by clearing cicr.ien. the pc low byte is pushed onto system stack. the pc high byte is pushed onto system stack. if encsr is set, csr is pushed onto system stack. the flag register is pushed onto system stack. the pc is loaded with the 16-bit vector stored in the vector table, pointed to by the ivr. if encsr is set, csr is loaded with isr con- tents; otherwise isr is used in place of csr until iret instruction. end of interrupt routine the interrupt service routine must be ended with the iret instruction. the iret instruction exe- cutes the following operations: the flag register is popped from system stack. if encsr is set, csr is popped from system stack. the pc high byte is popped from system stack. the pc low byte is popped from system stack. all unmasked interrupts are enabled by setting the cicr.ien bit. if encsr is reset, csr is used instead of isr. normal program execution thus resumes at the in- terrupted instruction. all pending interrupts remain pending until the next ei instruction (even if it is executed during the interrupt service routine). note : in concurrent mode, the source priority level is only useful during the arbitration phase, where it is compared with all other priority levels and with the cpl. no trace is kept of its value during the isr. if other requests are issued during the inter- rupt service routine, once the global cicr.ien is re-enabled, they will be acknowledged regardless of the interrupt service routine's priority. this may cause undesirable interrupt response sequences. highest position lowest position inta0 inta1 intb0 intb1 intc0 intc1 intd0 intd1 usb mft sci i2c int0/wdt int1/adc int2 int3 int4/ int5 int6/rccu int7/wkup 6 5 4 7 priority level main cpl is set to 5 cpl=7 main int 6 cpl=6 int6 ei cpl is set to 7 cpl6 > cpl5: int6 pending interrupt 6 has priority level 6 by main program
50/224 st92163 - interrupts arbitration modes (cont'd) examples in the following two examples, three interrupt re- quests with different priority levels (2, 3 & 4) occur simultaneously during the interrupt 5 service rou- tine. example 1 in the first example, (simplest case, figure 22) the ei instruction is not used within the interrupt serv- ice routines. this means that no new interrupt can be serviced in the middle of the current one. the interrupt routines will thus be serviced one after another, in the order of their priority, until the main program eventually resumes. figure 22. simple example of a sequence of interrupt requests with: - concurrent mode selected and - ien unchanged by the interrupt routines 6 5 4 3 2 1 0 7 priority level of main int 5 int 2 int 3 int 4 main int 5 int 4 int 3 int 2 cpl is set to 7 cpl = 7 cpl = 7 cpl = 7 cpl = 7 cpl = 7 ei interrupt 2 has priority level 2 interrupt 3 has priority level 3 interrupt 4 has priority level 4 interrupt 5 has priority level 5 interrupt request
51/224 st92163 - interrupts arbitration modes (cont'd) example 2 in the second example, (more complex, figure 23), each interrupt service routine sets interrupt enable with the ei instruction at the beginning of the routine. placed here, it minimizes response time for requests with a higher priority than the one being serviced. the level 2 interrupt routine (with the highest prior- ity) will be acknowledged first, then, when the ei instruction is executed, it will be interrupted by the level 3 interrupt routine, which itself will be inter- rupted by the level 4 interrupt routine. when the level 4 interrupt routine is completed, the level 3 in- terrupt routine resumes and finally the level 2 inter- rupt routine. this results in the three interrupt serv- ice routines being executed in the opposite order of their priority. it is therefore recommended to avoid inserting the ei instruction in the interrupt service rou- tine in concurrent mode . use the ei instruc- tion only in nested mode. warning: if, in concurrent mode, interrupts are nested (by executing ei in an interrupt service routine), make sure that either encsr is set or csr=isr, otherwise the iret of the innermost in- terrupt will make the cpu use csr instead of isr before the outermost interrupt service routine is terminated, thus making the outermost routine fail. figure 23. complex example of a sequence of interrupt requests with: - concurrent mode selected - ien set to 1 during interrupt service routine execution 6 5 4 3 2 1 0 7 main int 5 int 2 int 3 int 4 int 5 int 4 int 3 int 2 cpl is set to 7 cpl = 7 cpl = 7 cpl = 7 cpl = 7 cpl = 7 ei interrup t 2 has priority level 2 interrup t 3 has priority level 3 interrup t 4 has priority level 4 interrup t 5 has priority level 5 int 2 int 3 cpl = 7 cpl = 7 int 5 cpl = 7 main ei ei ei priority level of interrupt request ei
52/224 st92163 - interrupts arbitration modes (cont'd) 3.5.2 nested mode the difference between nested mode and con- current mode, lies in the modification of the cur- rent priority level (cpl) during interrupt process- ing. the arbitration phase is basically identical to con- current mode, however, once the request is ac- knowledged, the cpl is saved in the nested inter- rupt control register (nicr) by setting the nicr bit corresponding to the cpl value (i.e. if the cpl is 3, the bit 3 will be set). the cpl is then loaded with the priority of the re- quest just acknowledged; the next arbitration cycle is thus performed with reference to the priority of the interrupt service routine currently being exe- cuted. start of interrupt routine the interrupt cycle performs the following steps: all maskable interrupt requests are disabled by clearing cicr.ien. cpl is saved in the special nicr stack to hold the priority level of the suspended routine. priority level of the acknowledged routine is stored in cpl, so that the next request priority will be compared with the one of the routine cur- rently being serviced. the pc low byte is pushed onto system stack. the pc high byte is pushed onto system stack. if encsr is set, csr is pushed onto system stack. the flag register is pushed onto system stack. the pc is loaded with the 16-bit vector stored in the vector table, pointed to by the ivr. if encsr is set, csr is loaded with isr con- tents; otherwise isr is used in place of csr until iret instruction. figure 24. simple example of a sequence of interrupt requests with: - nested mode - ien unchanged by the interrupt routines 6 5 4 3 2 1 0 7 main int 2 int0 int4 int3 int2 cpl is set to 7 cpl=2 cpl=7 ei inte rrupt 2 has priority level 2 inte rrupt 3 has priority level 3 inte rrupt 4 has priority level 4 inte rrupt 5 has priority level 5 main int 3 cpl=3 int 6 cpl=6 int5 int 0 cpl=0 int6 int2 inte rrupt 6 has priority level 6 inte rrupt 0 has priority level 0 cpl6 > cpl3: int6 pending cpl2 < cpl4: serviced next int 2 cpl=2 int 4 cpl=4 int 5 cpl=5 priority level of interrupt request
53/224 st92163 - interrupts arbitration modes (cont'd) end of interrupt routine the iret interrupt return instruction executes the following steps: the flag register is popped from system stack. if encsr is set, csr is popped from system stack. the pc high byte is popped from system stack. the pc low byte is popped from system stack. all unmasked interrupts are enabled by setting the cicr.ien bit. the priority level of the interrupted routine is popped from the special register (nicr) and copied into cpl. if encsr is reset, csr is used instead of isr, unless the program returns to another nested routine. the suspended routine thus resumes at the inter- rupted instruction. figure 24 contains a simple example, showing that if the ei instruction is not used in the interrupt service routines, nested and concurrent modes are equivalent. figure 25 contains a more complex example showing how nested mode allows nested interrupt processing (enabled inside the interrupt service routines using the ei instruction) according to their priority level. figure 25. complex example of a sequence of interrupt requests with: - nested mode - ien set to 1 during the interrupt routine execution int 2 int 3 cpl=3 int 0 cpl=0 int6 6 5 4 3 2 1 0 7 main int 5 int 4 int0 int4 int3 int2 cpl is set to 7 cpl=5 cpl=4 cpl=2 cpl=7 ei interrupt 2 has priori ty level 2 interrupt 3 has priori ty level 3 interrupt 4 has priori ty level 4 interrupt 5 has priori ty level 5 int 2 int 4 cpl=2 cpl=4 int 5 cpl=5 main ei ei int 2 cpl=2 int 6 cpl=6 int5 int2 ei interrupt 6 has priori ty level 6 interrupt 0 has priori ty level 0 cpl6 > cpl3: int6 pending cpl2 < cpl4: serviced just after ei priority level of interrupt request ei
54/224 st92163 - interrupts 3.6 external interrupts the standard st9 core contains 8 external inter- rupts sources grouped into four pairs. int7 is connected to 8 different i/o pins of port 3. once these pins are programmed as alternate function they are able to generate an interrupt. table 11. external interrupt channel grouping int0 .. 6 have a trigger control bit tea0,..ted1 (r242,eitr.0,..,7 page 0) to select triggering on the rising or falling edge of the external pin. if the trigger control bit is set to a1o, the corresponding pending bit ipa0,..,ipd1 (r243, eipr.0,..,6 page 0) is set on the input pin rising edge, if it is cleared, the pending bit is set on the falling edge of the in- put pin. each source can be individually masked through the corresponding control bit ima0,..,imd1 (eimr.6,..,0). see figure 27. int7 is falling edge sensitive only, bit eimr.7 must always be cleared. the priority level of the external interrupt sources can be programmed among the eight priority lev- els with the control register eiplr (r245). the pri- ority level of each pair is software defined using the bits prl2, prl1. for each pair, the even channel (a0,b0,c0,d0) of the group has the even priority level and the odd channel (a1,b1,c1,d1) has the odd (lower) priority level. figure 26. priority level examples n figure 26 shows an example of priority levels. figure 27 gives an overview of the external inter- rupt control bits and vectors. the source of the interrupt channel a0 can be selected between the external pin int0 (when ia0s = a1o, the reset value) or the on-chip timer/ watchdog peripheral (when ia0s = a0o). the source of the interrupt channel a1 can be selected between the external pin int1 (when ad-int=a0o) or the on-chip adc peripheral (when ad-int=a1o, the reset value). the source of the interrupt channel d0 can be selected between the external pin int6 (when int_sel = a0o) or the on-chip rccu. warning: when using channels shared by both external interrupts and peripherals, special care must be taken to configure their control registers for both peripherals and interrupts. table 12. multiplexed interrupt sources external interrupt channel int7 int6 intd1 intd0 int5 int4 intc1 intc0 int3 int2 intb1 intb0 int1 int0 inta1 inta0 channel internal interrupt source external interrupt source inta0 timer/watchdog int0 inta1 adc int1 intd0 rccu int6 1 001001 pl2 d pl1d pl2 c pl1 c pl2b pl1b pl2a pl1a int.d1: int.c1: 001=1 int.d0: source priority priority source int.a0: 010=2 int.a1: 011=3 int.b1: 101=5 int.b0: 100=4 int.c0: 000=0 eiplr vr000151 0 100=4 101=5
55/224 st92163 - interrupts external interrupts (cont'd) figure 27. external interrupts control bits and vectors inta0 request vector priority level mask bit pending bit ima0 ipa0 v7 v6 v5 v4 0 00x a0o a1o ia0s watchdog/timer end of count int 0 pin int a1 request tea1 int 1 pin int b0 request int 2 pin int b1 request teb1 int 3 pin int c0 request int 4 pin int c1 request tec1 int 5 pin int d0 request ted0 int 6 pin int d1 request p3.[7:0] vector priority level mask bit pending bit ima1 ipa1 v7 v6 v5 v4 0 0 1 x v7 v6 v5 v4 0 1 0x v7 v6 v5 v4 0 11x v7 v6 v5 v4 1 0 0 x v7 v6 v5 v4 1 0 1 x v7 v6 v5 v4 1 1 0 x v7 v6 v5 v4 1 11x vecto r priority level vector priority level vecto r priority level vector priority level vector priority level vector priority level mask bit imb0 pending bit ipb0 pending bit ipb1 pending bit ipc0 pending bit ipc1 pending bit ipd0 pending bit ipd1 mask bit imb1 mask bit imc0 mask bit imc1 mask bit imd0 mask bit imd1 * shared channels, see warning * ad-int adc a1o a0o int_sel rccu a1o a0o tea0 tec0 teb0 * * int 7 pins 0 pl2a pl1a 0 pl2b pl1b 1 pl2a pl1a 1 pl2b pl1b 0 pl2c pl1c 1 pl2c pl1c 0 pl2d pl1d 1 pl2d pl1d a0o a1o id1s * wake-up controller wkup [13:0] pins ted1 wkup14 p1.[7:0] pins
56/224 st92163 - interrupts 3.7 management of wake-up lines and external interrupt lines in the st92163, fifteen wake-up lines (wkup[14:0]) are available on external pins. the wkup[15] line is internally connected to the usb interfaceline. figure 28 shows the connections of the external interrupt lines int7[7:0] and the wake-up/inter- rupt lines managed through the wuimu on the intd1 interrupt channel. figure 28. wake-up lines and external interrupt lines management trigger registers pending registers mask registers 10 int7[7:0] wkup[7:0] wkup[13:8] (to cpu) external interrupt wuimu stop sw setting wuctrl register intd1 (to rccu) id1s bit wkup14 wkup14[7:0] usb interface wkup15 esusp usbistr register
57/224 st92163 - interrupts 3.8 top level interrupt the top level interrupt channel can be assigned either to the external pin nmi or to the timer/ watchdog according to the status of the control bit eivr.tlis (r246.2, page 0). if this bit is high (the reset condition) the source is the external pin nmi. if it is low, the source is the timer/ watchdog end of count. when the source is the nmi external pin, the control bit eivr.tltev (r246.3; page 0) selects between the rising (if set) or falling (if reset) edge generating the interrupt request. when the selected event occurs, the cicr.tlip bit (r230.6) is set. depending on the mask situation, a top level interrupt request may be generated. two kinds of masks are available, a maskable mask and a non-maskable mask. the first mask is the cicr.tli bit (r230.5): it can be set or cleared to enable or disable respectively the top level inter- rupt request. if it is enabled, the global enable in- terrupt bit, cicr.ien (r230.4; page 0) must also be enabled in order to allow a top level request. the second mask nicr.tlnm (r247.7; page 0) is a set-only mask. once set, it enables the top level interrupt request independently of the value of cicr.ien and it cannot be cleared by the pro- gram. only the processor reset cycle can clear this bit. this does not prevent the user from ignor- ing some sources due to a change in tlis. the top level interrupt service routine cannot be interrupted by any other interrupt or dma request, in any arbitration mode, not even by a subsequent top level interrupt request. warning . the interrupt machine cycle of the top level interrupt does not clear the cicr.ien bit, and the corresponding iret does not set it. 3.9 on-chip peripheral interrupts the general structure of the peripheral interrupt unit is described here, however each on-chip pe- ripheral has its own specific interrupt unit contain- ing one or more interrupt channels, or dma chan- nels. please refer to the specific peripheral chap- ter for the description of its interrupt features and control registers. the on-chip peripheral interrupt channels provide the following control bits: interrupt pending bit (ip). set by hardware when the trigger event occurs. can be set/ cleared by software to generate/cancel pending interrupts and give the status for interrupt polling. interrupt mask bit (im). if im = a0o, no interrupt request is generated. if im =a1o an interrupt re- quest is generated whenever ip = a1o and cicr.ien = a1o. priority level (prl, 3 bits). these bits define the current priority level, prl=0: the highest pri- ority, prl=7: the lowest priority (the interrupt cannot be acknowledged) interrupt vector register (ivr, up to 7 bits). the ivr points to the vector table which itself contains the interrupt routine start address. figure 29. top level interrupt structure watchdog enable wden watchdog timer end of count nmi or tltev mux tlis tlip tlnm tli ien pending mask top level interrupt va00294 core reset request
58/224 st92163 - interrupts 3.10 interrupt response time the interrupt arbitration protocol functions com- pletely asynchronously from instruction flow, and requires 6 cpuclk cycles to resolve the request's priority. requests are sampled every 5 cpuclk cycles. if the interrupt request comes from an external pin, the trigger event must occur a minimum of one intclk cycle before the sampling time. when an arbitration results in an interrupt request being generated, the interrupt logic checks if the current instruction (which could be at any stage of execution) can be safely aborted; if this is the case, instruction execution is terminated immedi- ately and the interrupt request is serviced; if not, the cpu waits until the current instruction is termi- nated and then services the request. instruction execution can normally be aborted provided no write operation has been performed. for an interrupt deriving from an external interrupt channel, the response time between a user event and the start of the interrupt service routine can range from a minimum of 26 clock cycles to a max- imum of 48 clock cycles. for a non-maskable top level interrupt, the re- sponse time between a user event and the start of the interrupt service routine can range from a min- imum of 22 clock cycles to a maximum of 48 clock cycles. in order to guarantee edge detection, input signals must be kept low/high for a minimum of one intclk cycle. an interrupt machine cycle requires a basic 18 in- ternal clock cycles (cpuclk), to which must be added a further 2 clock cycles if the stack is in the register file. 2 more clock cycles must further be added if the csr is pushed (encsr =1). the interrupt machine cycle duration forms part of the two examples of interrupt response time previ- ously quoted; it includes the time required to push values on the stack, as well as interrupt vector handling. in wait for interrupt mode, a further cycle is re- quired as wake-up delay.
59/224 st92163 - interrupts 3.11 interrupt registers central interrupt control register (cicr) r230 - read/write register page: system reset value: 1000 0111 (87h) bit 7 = gcen : global counter enable. this bit enables the 16-bit multifunction timer pe- ripheral. 0: mft disabled 1: mft enabled bit 6 = tlip : top level interrupt pending . this bit is set by hardware when top level inter- rupt (tli) trigger event occurs. it is cleared by hardware when a tli is acknowledged. it can also be set by software to implement a software tli. 0: no tli pending 1: tli pending bit 5 = tli : top level interrupt. this bit is set and cleared by software. 0: generate a top level interrupt only if tlnm=1 1: generate a top level interrupt request when the ien and tlip bits=1. bit 4 = ien : interrupt enable . this bit is cleared by the interrupt machine cycle (except for a tli). it is set by the iret instruction (except for a return from tli). it is set by the ei instruction. it is cleared by the di instruction. 0: maskable interrupts disabled 1: maskable interrupts enabled note: the ien bit can also be changed by soft- ware using any instruction that operates on regis- ter cicr, however in this case, take care to avoid spurious interrupts, since ien cannot be cleared in the middle of an interrupt arbitration. only modify the ien bit when interrupts are disabled or when no peripheral can generate interrupts. for exam- ple, if the state of ien is not known in advance, and its value must be restored from a previous push of cicr on the stack, use the sequence di; pop cicr to make sure that no interrupts are be- ing arbitrated when cicr is modified. bit 3 = iam : interrupt arbitration mode . this bit is set and cleared by software. 0: concurrent mode 1: nested mode bit 2:0 = cpl[2:0]: current priority level . these bits define the current priority level. cpl=0 is the highest priority. cpl=7 is the lowest priority. these bits may be modified directly by the interrupt hardware when nested interrupt mode is used. external interrupt trigger register (eitr) r242 - read/write register page: 0 reset value: 0000 0000 (00h) bit 7 = ted1 : intd1 trigger event must always stay cleared bit 6 = ted0 : intd0 trigger event bit 5 = tec1 : intc1 trigger event bit 4 = tec0 : intc0 trigger event bit 3 = teb1 : intb1 trigger event bit 2 = teb0 : intb0 trigger event bit 1 = tea1 : inta1 trigger event bit 0 = tea0 : inta0 trigger event these bits are set and cleared by software. 0: select falling edge as interrupt trigger event 1: select rising edge as interrupt trigger event 70 gcen tlip tli ien iam cpl2 cpl1 cpl0 70 ted1 ted0 tec1 tec0 teb1 teb0 tea1 tea0
60/224 st92163 - interrupts interrupt registers (cont'd) external interrupt pending register (eipr) r243 - read/write register page: 0 reset value: 0000 0000 (00h) bit 7 = ipd1 : intd1 interrupt pending bit bit 6 = ipd0 : intd0 interrupt pending bit bit 5 = ipc1 : intc1 interrupt pending bit bit 4 = ipc0 : intc0 interrupt pending bit bit 3 = ipb1 : intb1 interrupt pending bit bit 2 = ipb0 : intb0 interrupt pending bit bit 1 = ipa1 : inta1 interrupt pending bit bit 0 = ipa0 : inta0 interrupt pending bit these bits are set by hardware on occurrence of a trigger event (as specified in the eitr register) and are cleared by hardware on interrupt acknowl- edge. they can also be set by software to imple- ment a software interrupt. 0: no interrupt pending 1: interrupt pending external interrupt mask-bit register (eimr) r244 - read/write register page: 0 reset value: 0000 0000 (00h ) bit 7 = imd1 : intd1 interrupt mask bit 6 = imd0 : intd0 interrupt mask bit 5 = imc1 : intc1 interrupt mask bit 4 = imc0 : intc0 interrupt mask bit 3 = imb1 : intb1 interrupt mask bit 2 = imb0 : intb0 interrupt mask bit 1 = ima1 : inta1 interrupt mask bit 0 = ima0 : inta0 interrupt mask these bits are set and cleared by software. 0: interrupt masked 1: interrupt not masked (an interrupt is generated if the ipxx and ien bits = 1) external interrupt priority level register (eiplr) r245 - read/write register page: 0 reset value: 1111 1111 (ffh ) bit 7:6 = pl2d, pl1d: intd0, d1 priority level. bit 5:4 = pl2c, pl1c : intc0, c1 priority level. bit 3:2 = pl2b, pl1b : intb0, b1 priority level. bit 1:0 = pl2a, pl1a : inta0, a1 priority level. these bits are set and cleared by software. the priority is a three-bit value. the lsb is fixed by hardware at 0 for channels a0, b0, c0 and d0 and at 1 for channels a1, b1, c1 and d1. 70 ipd1 ipd0 ipc1 ipc0 ipb1 ipb0 ipa1 ipa0 70 imd1 imd0 imc1 imc0 imb1 imb0 ima1 ima0 70 pl2d pl1d pl2c pl1c pl2b pl1b pl2a pl1a pl2x pl1x hardware bit priority 00 0 1 0 (highest) 1 01 0 1 2 3 10 0 1 4 5 11 0 1 6 7 (lowest)
61/224 st92163 - interrupts interrupt registers (cont'd) external interrupt vector register (eivr ) r246 - read/write register page: 0 reset value: xxxx 0110 (x6h) bit 7:4 = v[7:4] : most significant nibble of external interrupt vector . these bits are not initialized by reset. for a repre- sentation of how the full vector is generated from v[7:4] and the selected external interrupt channel, refer to figure 27. bit 3 = tltev : top level trigger event bit. this bit is set and cleared by software. 0: select falling edge as nmi trigger event 1: select rising edge as nmi trigger event bit 2 = tlis : top level input selection . this bit is set and cleared by software. 0: watchdog end of count is tl interrupt source 1: nmi is tl interrupt source bit 1 = ia0s : interrupt channel a0 selection. this bit is set and cleared by software. 0: watchdog end of count is inta0 source 1: external interrupt pin is inta0 source bit 0 = ewen : external wait enable. this bit is set and cleared by software. 0: waitn pin disabled 1: waitn pin enabled (to stretch the external memory access cycle). note: for more details on wait mode refer to the section describing the waitn pin in the external memory chapter. nested interrupt control (nicr) r247 - read/write register page: 0 reset value: 0000 0000 (00h) bit 7 = tlnm : top level not maskable . this bit is set by software and cleared only by a hardware reset. 0: top level interrupt maskable. a top level re- quest is generated if the ien, tli and tlip bits =1 1: top level interrupt not maskable. a top level request is generated if the tlip bit =1 bit 6:0 = hl[6:0] : hold level x these bits are set by hardware when, in nested mode, an interrupt service routine at level x is in- terrupted from a request with higher priority (other than the top level interrupt request). they are cleared by hardware at the iret execution when the routine at level x is recovered. 70 v7 v6 v5 v4 tltev tlis iaos ewen 70 tlnm hl6 hl5 hl4 hl3 hl2 hl1 hl0
62/224 st92163 - interrupts interrupt registers (cont'd) external memory register 2 (emr2) r246 - read/write register page: 21 reset value: 0000 1111 (0fh) bit 7, 5:0 = reserved, keep in reset state. refer to the external memory interface chapter. bit 6 = encsr : enable code segment register. this bit is set and cleared by software. it affects the st9 cpu behaviour whenever an interrupt re- quest is issued. 0: the cpu works in original st9 compatibility mode. for the duration of the interrupt service routine, isr is used instead of csr, and the in- terrupt stack frame is identical to that of the orig- inal st9: only the pc and flags are pushed. this avoids saving the csr on the stack in the event of an interrupt, thus ensuring a faster in- terrupt response time. the drawback is that it is not possible for an interrupt service routine to perform inter-segment calls or jumps: these in- structions would update the csr, which, in this case, is not used (isr is used instead). the code segment size for all interrupt service rou- tines is thus limited to 64k bytes. 1: isr is only used to point to the interrupt vector table and to initialize the csr at the beginning of the interrupt service routine: the old csr is pushed onto the stack together with the pc and flags, and csr is then loaded with the contents of isr. in this case, iret will also restore the csr from the stack. this approach allows inter- rupt service routines to access the entire 4 mbytes of address space; the drawback is that the interrupt response time is slightly increased, because of the need to also save the csr on the stack. full compatibility with the original st9 is lost in this case, because the interrupt stack frame is different; this difference, however, should not affect the vast majority of programs. 70 0 encsr 0 0 1 1 1 1
63/224 st92163 - interrupts 3.12 wake-up / interrupt lines management unit (wuimu) 3.12.1 introduction the wake-up/interrupt management unit extends the number of external interrupt lines from 8 to 23 (depending on the number of external interrupt lines mapped on external pins of the device). it al- lows the source of the intd1 external interrupt channel to be selected between the int7 pin and up to 16 additional external wake-up/interrupt pins. these 16 wkup pins can be programmed as ex- ternal interrupt lines or as wake-up lines, able to exit the microcontroller from low power mode (stop mode) (see figure 30). 3.12.2 main features n supports up to 16 additional external wake-up or interrupt lines n wake-up lines can be used to wake-up the st9 from stop mode. n programmable selection of wake-up or interrupt n programmable wake-up trigger edge polarity n all wake-up lines maskable note: the number of available pins is device de- pendent. refer to the device pinout description. figure 30. wake-up lines / interrupt management unit block diagram wutrh wutrl wuprh wuprl wumrh wumrl triggering level registers pending request registers mask registers wkup[ 7:0] wkup[15:8] 10 set wuctr l sw sett ing wkup-int id1s stop reset to rccu - stop mode control to cpu intd1 - external interrupt channel int7 stop note: reset signal on stop bit is stronger than the set signal
64/224 st92163 - interrupts wake-up / interrupt lines management unit (cont'd) 3.12.3 functional description 3.12.3.1 interrupt mode to configure the 16 wake-up lines as interrupt sources, use the following procedure: 1. configure the mask bits of the 16 wake-up lines (wumrl, wumrh). 2. configure the triggering edge registers of the wake-up lines (wutrl, wutrh). 3. set bit 7 of eimr (r244 page 0) and eitr (r242 page 0) registers of the cpu: so an interrupt coming from one of the 16 lines can be correctly acknowledged. 4. reset the wkup-int bit in the wuctrl regis- ter to disable wake-up mode. 5. set the id1s bit in the wuctrl register to dis- able the int7 external interrupt source and enable the 16 wake-up lines as external inter- rupt source lines. to return to standard mode (int7 external inter- rupt source enabled and 16 wake-up lines disa- bled) it is sufficient to reset the id1s bit. 3.12.3.2 wake-up mode selection to configure the 16 lines as wake-up sources, use the following procedure: 1. configure the mask bits of the 16 wake-up lines (wumrl, wumrh). 2. configure the triggering edge registers of the wake-up lines (wutrl, wutrh). 3. set, as for interrupt mode selection, bit 7 of eimr and eitr registers only if an interrupt routine is to be executed after a wake-up event. otherwise, if the wake-up event only restarts the execution of the code from where it was stopped, the intd1 interrupt channel must be masked or the external source must be selected by resetting the id1s bit. 4. since the rccu can generate an interrupt request when exiting from stop mode, take care to mask it even if the wake-up event is only to restart code execution. 5. set the wkup-int bit in the wuctrl register to select wake-up mode. 6. set the id1s bit in the wuctrl register to dis- able the int7 external interrupt source and enable the 16 wake-up lines as external inter- rupt source lines. this is not mandatory if the wake-up event does not require an interrupt response. 7. write the sequence 1,0,1 to the stop bit of the wuctrl register with three consecutive write operations. this is the stop bit setting sequence. to detect if stop mode was entered or not, im- mediately after the stop bit setting sequence, poll the rccu ex_stp bit (r242.7, page 55) and the stop bit itself. 3.12.3.3 stop mode entry conditions assuming the st9 is in run mode: during the stop bit setting sequence the following cases may occur: case 1: wrong stop bit setting sequence this can happen if an interrupt/dma request is ac- knowledged during the stop bit setting se- quence. in this case polling the stop and ex_stp bits will give: stop = 0, ex_stp = 0 this means that the st9 did not enter stop mode due to a bad stop bit setting sequence: the user must retry the sequence. case 2: correct stop bit setting sequence in this case the st9 enters stop mode. to exit stop mode, a wake-up interrupt must be acknowledged. that implies: stop = 0, ex_stp = 1 this means that the st9 entered and exited stop mode due to an external wake-up line event.
65/224 st92163 - interrupts wake-up / interrupt lines management unit (cont'd) case 3: a wake-up event on the external wake- up lines occurs during the stop bit setting se- quence there are two possible cases: 1. interrupt requests to the cpu are disabled: in this case the st9 will not enter stop mode, no interrupt service routine will be executed and the program execution continues from the instruction following the stop bit setting sequence. the status of stop and ex_stp bits will be again: stop = 0, ex_stp = 0 the application can determine why the st9 did not enter stop mode by polling the pending bits of the external lines (at least one must be at 1). 2. interrupt requests to cpu are enabled: in this case the st9 will not enter stop mode and the interrupt service routine will be executed. the status of stop and ex_stp bits will be again: stop = 0, ex_stp = 0 the interrupt service routine can determine why the st9 did not enter stop mode by polling the pending bits of the external lines (at least one must be at 1). if the mcu really exits from stop mode, the rccu ex_stp bit is still set and must be reset by software. otherwise, if an interrupt/dma request was acknowledged during the stop bit setting se- quence, the rccu ex_stp bit is reset. this means that the mcu has filtered the stop mode entry request. the wkup-int bit can be used by an interrupt routine to detect and to distinguish events coming from interrupt mode or from wake-up mode, allow- ing the code to execute different procedures. to exit stop mode, it is sufficient that one of the 16 wake-up lines (not masked) generates an event: the clock restarts after the delay needed for the oscillator to restart. note: after exiting from stop mode, the software can successfully reset the pending bits (edge sen- sitive), even though the corresponding wake-up line is still active (high or low, depending on the trigger event register programming); the user must poll the external pin status to detect and dis- tinguish a short event from a long one (for example keyboard input with keystrokes of varying length).
66/224 st92163 - interrupts wake-up / interrupt lines management unit (cont'd) 3.12.4 programming considerations the following paragraphs give some guidelines for designing an application program. 3.12.4.1 procedure for entering/exiting stop mode 1. program the polarity of the trigger event of external wake-up lines by writing registers wutrh and wutrl. 2. check that at least one mask bit (registers wumrh, wumrl) is equal to 1 (so at least one external wake-up line is not masked). 3. reset at least the unmasked pending bits: this allows a rising edge to be generated on the intd1 channel when the trigger event occurs (an interrupt on channel intd1 is recognized when a rising edge occurs). 4. select the interrupt source of the intd1 chan- nel (see description of id1s bit in the wuctrl register) and set the wkup-int bit. 5. to generate an interrupt on channel intd1, bits eitr.1 (r242.7, page 0) and eimr.1 (r244.7, page 0) must be set and bit eipr.7 must be reset. bits 7 and 6 of register r245, page 0 must be written with the desired priority level for interrupt channel intd1. 6. reset the stop bit in register wuctrl and the ex_stp bit in the clk_flag register (r242.7, page 55). refer to the rccu chapter. 7. to enter stop mode, write the sequence 1, 0, 1 to the stop bit in the wuctrl register with three consecutive write operations. 8. the code to be executed just after the stop sequence must check the status of the stop and rccu ex_stp bits to determine if the st9 entered stop mode or not (see awake-up mode selectiono on page 64. for details). if the st9 did not enter in stop mode it is necessary to reloop the procedure from the beginning, oth- erwise the procedure continues from next point. 9. poll the wake-up pending bits to determine which wake-up line caused the exit from stop mode. 10.clear the wake-up pending bit that was set. 3.12.4.2 simultaneous setting of pending bits it is possible that several simultaneous events set different pending bits. in order to accept subse- quent events on external wake-up/interrupt lines, it is necessary to clear at least one pending bit: this operation allows a rising edge to be generated on the intd1 line (if there is at least one more pend- ing bit set and not masked) and so to set eipr.7 bit again. a further interrupt on channel intd1 will be serviced depending on the status of bit eimr.7. two possible situations may arise: 1. the user chooses to reset all pending bits: no further interrupt requests will be generated on channel intd1. in this case the user has to: reset eimr.7 bit (to avoid generating a spuri- ous interrupt request during the next reset op- eration on the wuprh register) reset wuprh register using a read-modify- write instruction (and, bres, band) clear the eipr.7 bit reset the wuprl register using a read-mod- ify-write instruction (and, bres, band) 2. the user chooses to keep at least one pending bit active: at least one additional interrupt request will be generated on the intd1 chan- nel. in this case the user has to reset the desired pending bits with a read-modify-write instruction (and, bres, band). this operation will generate a rising edge on the intd1 chan- nel and the eipr.7 bit will be set again. an interrupt on the intd1 channel will be serviced depending on the status of eimr.7 bit.
67/224 st92163 - interrupts wake-up / interrupt lines management unit (cont'd) 3.12.5 register description wake-up control register ( wuctrl) r249 - read/write register page: 57 reset value: 0000 0000 (00h) bit 2 = stop: stop bit. to enter stop mode, write the sequence 1,0,1 to this bit with three consecutive write operations . when a correct sequence is recognized, the stop bit is set and the rccu puts the mcu in stop mode. the software sequence succeeds only if the following conditions are true: the wkup-int bit is 1, all unmasked pending bits are reset, at least one mask bit is equal to 1 (at least one external wake-up line is not masked). otherwise the mcu cannot enter stop mode, the program code continues executing and the stop bit remains cleared. the bit is reset by hardware if, while the mcu is in stop mode, a wake-up interrupt comes from any of the unmasked wake-up lines. the stop bit is at 1 in the two following cases (see awake-up mode selectiono on page 64. for details): after the first write instruction of the sequence (a 1 is written to the stop bit) at the end of a successful sequence (i.e. after the third write instruction of the sequence) note : the stop request generated by the wuimu (that allows the st9 to enter stop mode) is ored with the external stop pin (active low). this means that if the external stop pin is forced low, the st9 will enter stop mode independently of the status of the stop bit. warning : writing the sequence 1,0,1 to the stop bit will enter stop mode only if no other register write instructions are executed during the sequence. if interrupt or dma requests (which al- ways perform register write operations) are ac- knowledged during the sequence, the st9 will not enter stop mode: the user must re-enter the se- quence to set the stop bit. warning : whenever a stop request is issued to the mcu, a few clock cycles are needed to enter stop mode (see rccu chapter for further de- tails). hence the execution of the instruction fol- lowing the stop bit setting sequence might start before entering stop mode: if such instruction performs a register write operation, the st9 will not enter in stop mode. in order to avoid to exe- cute register write instructions after a correct stop bit setting sequence and before entering the stop mode, it is mandatory to execute 3 nop instructions after the stop bit setting sequence. bit 1 = id1s: interrupt channel intd1 source. this bit is set and cleared by software. 0: int7 external interrupt source selected, exclud- ing wake-up line interrupt requests 1: the 16 external wake-up lines enabled as inter- rupt sources, replacing the int7 external pin function warning: to avoid spurious interrupt requests on the intd1 channel due to changing the inter- rupt source, do the following before modifying the id1s bit: 1. mask the intd1 interrupt channel (bit 7 of reg- ister eimr - r244, page 0 - reset to 0). 2. program the id1s bit as needed. 3. clear the ipd1 interrupt pending bit (bit 7 of register eipr - r243, page 0). 4. remove the mask on intd1 (bit eimr.7=1). bit 0 = wkup-int: wakeup interrupt. this bit is set and cleared by software. 0: the 16 external wakeup lines can be used to generate interrupt requests 1: the 16 external wake-up lines to work as wake- up sources for exiting from stop mode 70 -----stop id1s wkup- int
68/224 st92163 - interrupts wake-up / interrupt lines management unit (cont'd) wake-up mask register high ( wumrh) r250 - read/write register page: 57 reset value: 0000 0000 (00h) bit 7:0 = wum[15:8]: wake-up mask bits. if wumx is set, an interrupt on channel intd1 and/or a wake-up event (depending on id1s and wkup-int bits) are generated if the correspond- ing wupx pending bit is set. more precisely, if wumx=1 and wupx=1 then: if id1s=1 and wkup-int=1 then an interrupt on channel intd1 and a wake-up event are gener- ated. if id1s=1 and wkup-int=0 only an interrupt on channel intd1 is generated. if id1s=0 and wkup-int=1 only a wake-up event is generated. if id1s=0 and wkup-int=0 neither interrupts on channel intd1 nor wake-up events are gen- erated. interrupt requests on channel intd1 may be generated only from external interrupt source int7. if wumx is reset, no wake-up events can be gen- erated. interrupt requests on channel intd1 may be generated only from external interrupt source int7 (resetting id1s bit to 0). wake-up mask register low ( wumrl) r251 - read/write register page: 57 reset value: 0000 0000 (00h) bit 7:0 = wum[7:0]: wake-up mask bits. if wumx is set, an interrupt on channel intd1 and/or a wake-up event (depending on id1s and wkup-int bits) are generated if the correspond- ing wupx pending bit is set. more precisely, if wumx=1 and wupx=1 then: if id1s=1 and wkup-int=1 then an interrupt on channel intd1 and a wake-up event are gener- ated. if id1s=1 and wkup-int=0 only an interrupt on channel intd1 is generated. if id1s=0 and wkup-int=1 only a wake-up event is generated. if id1s=0 and wkup-int=0 neither interrupts on channel intd1 nor wake-up events are gen- erated. interrupt requests on channel intd1 may be generated only from external interrupt source int7. if wumx is reset, no wake-up events can be gen- erated. interrupt requests on channel intd1 may be generated only from external interrupt source int7 (resetting id1s bit to 0). 70 wum15 wum14 wum13 wum12 wum11 wum10 wum9 wum8 70 wum7 wum6 wum5 wum4 wum3 wum2 wum1 wum0
69/224 st92163 - interrupts wake-up / interrupt lines management unit (cont'd) wake-up trigger register high ( wutrh) r252 - read/write register page: 57 reset value: 0000 0000 (00h) bit 7:0 = wut[15:8]: wake-up trigger polarity bits these bits are set and cleared by software. 0: the corresponding wupx pending bit will be set on the falling edge of the input wake-up line. 1: the corresponding wupx pending bit will be set on the rising edge of the input wake-up line. wake-up trigger register low ( wutrl) r253 - read/write register page: 57 reset value: 0000 0000 (00h) bit 7:0 = wut[7:0]: wake-up trigger polarity bits these bits are set and cleared by software. 0: the corresponding wupx pending bit will be set on the falling edge of the input wake-up line. 1: the corresponding wupx pending bit will be set on the rising edge of the input wake-up line. warning 1. as the external wake-up lines are edge trig- gered, no glitches must be generated on these lines. 2. if either a rising or a falling edge on the external wake-up lines occurs while writing the wutrh or wutrl registers, the pending bit will not be set. wake-up pending register high ( wuprh) r254 - read/write register page: 57 reset value: 0000 0000 (00h) bit 7:0 = wup[15:8]: wake-up pending bits these bits are set by hardware on occurrence of the trigger event on the corresponding wake-up line. they must be cleared by software. they can be set by software to implement a software inter- rupt. 0: no wake-up trigger event occurred 1: wake-up trigger event occured wake-up pending register low ( wuprl) r255 - read/write register page: 57 reset value: 0000 0000 (00h) bit 7:0 = wup[7:0]: wake-up pending bits these bits are set by hardware on occurrence of the trigger event on the corresponding wake-up line. they must be cleared by software. they can be set by software to implement a software inter- rupt. 0: no wake-up trigger event occurred 1: wake-up trigger event occured note: to avoid losing a trigger event while clear- ing the pending bits, it is recommended to use read-modify-write instructions (and, bres, band) to clear them. 70 wut15 wut14 wut13 wut12 wut11 wut10 wut9 wut8 70 wut7 wut6 wut5 wut4 wut3 wut2 wut1 wut0 70 wup15 wup14 wup13 wup12 wup11 wup10 wup9 wup8 70 wup7 wup6 wup5 wup4 wup3 wup2 wup1 wup0
70/224 st92163 - on-chip direct memory access (dma) 4 on-chip direct memory access (dma) 4.1 introduction the st9 includes on-chip direct memory access (dma) in order to provide high-speed data transfer between peripherals and memory or register file. multi-channel dma is fully supported by peripher- als having their own controller and dma chan- nel(s). each dma channel transfers data to or from contiguous locations in the register file, or in memory. the maximum number of bytes that can be transferred per transaction by each dma chan- nel is 222 with the register file, or 65536 with memory. the dma controller in the peripheral uses an indi- rect addressing mechanism to dma pointers and counter registers stored in the register file. this is the reason why the maximum number of trans- actions for the register file is 222, since two reg- isters are allocated for the pointer and counter. register pairs are used for memory pointers and counters in order to offer the full 65536 byte and count capability. 4.2 dma priority levels the 8 priority levels used for interrupts are also used to prioritize the dma requests, which are ar- bitrated in the same arbitration phase as interrupt requests. if the event occurrence requires a dma transaction, this will take place at the end of the current instruction execution. when an interrupt and a dma request occur simultaneously, on the same priority level, the dma request is serviced before the interrupt. an interrupt priority request must be strictly higher than the cpl value in order to be acknowledged, whereas, for a dma transaction request, it must be equal to or higher than the cpl value in order to be executed. thus only dma transaction requests can be acknowledged when the cpl=0. dma requests do not modify the cpl value, since the dma transaction is not interruptable. figure 31. dma data transfer peripheral vr001834 data address counter transferred register file or memory register file register file start address counter value 0 df data group f peripheral paged registers
71/224 st92163 - on-chip direct memory access (dma) 4.3 dma transactions the purpose of an on-chip dma channel is to transfer a block of data between a peripheral and the register file, or memory. each dma transfer consists of three operations: a load from/to the peripheral data register to/ from a location of register file (or memory) ad- dressed through the dma address register (or register pair) a post-increment of the dma address register (or register pair) a post-decrement of the dma transaction coun- ter, which contains the number of transactions that have still to be performed. if the dma transaction is carried out between the peripheral and the register file (figure 32), one register is required to hold the dma address, and one to hold the dma transaction counter. these two registers must be located in the register file: the dma address register in the even address register, and the dma transaction counter in the next register (odd address). they are pointed to by the dma transaction counter pointer register (dcpr), located in the peripheral's paged regis- ters. in order to select a dma transaction with the register file, the control bit dcpr.rm (bit 0 of dcpr) must be set. if the transaction is made between the peripheral and memory , a register pair (16 bits) is required for the dma address and the dma transaction counter (figure 33). thus, two register pairs must be located in the register file. the dma transaction counter is pointed to by the dma transaction counter pointer register (dcpr), the dma address is pointed to by the dma address pointer register (dapr),both dcpr and dapr are located in the paged regis- ters of the peripheral. figure 32. dma between register file and peripheral idcr ivr dapr dcpr data paged registers registers system dma counter dma address ffh f0h e0h dfh efh memory 0000h data already transferred end of block interrupt service routine dma table dma transaction isr address 0100h vector table register file peripheral paged registers
72/224 st92163 - on-chip direct memory access (dma) dma transactions (cont'd) when selecting the dma transaction with memory, bit dcpr.rm (bit 0 of dcpr) must be cleared. to select between using the isr or the dmasr reg- ister to extend the address, (see memory manage- ment unit chapter), the control bit dapr.ps (bit 0 of dapr) must be cleared or set respectively. the dma transaction counter must be initialized with the number of transactions to perform and will be decremented after each transaction. the dma address must be initialized with the starting ad- dress of the dma table and is increased after each transaction. these two registers must be located between addresses 00h and dfh of the register file. once a dma channel is initialized, a transfer can start. the direction of the transfer is automatically defined by the type of peripheral and programming mode. once the dma table is completed (the transaction counter reaches 0 value), an interrupt request to the cpu is generated. when the interrupt pending (ip) bit is set by a hardware event (or by software), and the dma mask bit (dm) is set, a dma request is generated. if the priority level of the dma source is higher than, or equal to, the current priority level (cpl), the dma transfer is executed at the end of the cur- rent instruction. dma transfers read/write data from/to the location pointed to by the dma ad- dress register, the dma address register is incre- mented and the transaction counter register is decremented. when the contents of the transac- tion counter are decremented to zero, the dma mask bit (dm) is cleared and an interrupt request is generated, according to the interrupt mask bit (end of block interrupt). this end-of-block inter- rupt request is taken into account, depending on the prl value. warning . dma requests are not acknowledged if the top level interrupt service is in progress. figure 33. dma between memory and peripheral n idcr ivr dapr dcpr data paged registers registers system dma transaction counter dma address ffh f0h e0h dfh efh memory 0000h data already transferred end of block interrupt service routine dma table dma transaction isr address 0100h vector table register file peripheral paged registers
73/224 st92163 - on-chip direct memory access (dma) dma transactions (cont'd) 4.4 dma cycle time the interrupt and dma arbitration protocol func- tions completely asynchronously from instruction flow. requests are sampled every 5 cpuclk cycles. dma transactions are executed if their priority al- lows it. a dma transfer with the register file requires 8 cpuclk cycles. a dma transfer with memory requires 16 cpuclk cycles, plus any required wait states. 4.5 swap mode an extra feature which may be found on the dma channels of some peripherals (e.g. the multifunc- tion timer) is the swap mode. this feature allows transfer from two dma tables alternatively. all the dma descriptors in the register file are thus dou- bled. two dma transaction counters and two dma address pointers allow the definition of two fully in- dependent tables (they only have to belong to the same space, register file or memory). the dma transaction is programmed to start on one of the two tables (say table 0) and, at the end of the block, the dma controller automatically swaps to the other table (table 1) by pointing to the other dma descriptors. in this case, the dma mask (dm bit) control bit is not cleared, but the end of block interrupt request is generated to allow the optional updating of the first data table (table 0). until the swap mode is disabled, the dma control- ler will continue to swap between dma table 0 and dma table 1. n
74/224 st92163 - on-chip direct memory access (dma) 4.6 dma registers as each peripheral dma channel has its own spe- cific control registers, the following register list should be considered as a general example. the names and register bit allocations shown here may be different from those found in the peripheral chapters. dma counter pointer register (dcpr) read/write address set by peripheral reset value: undefined bit 7:1 = c[7:1] : dma transaction counter point- er. software should write the pointer to the dma transaction counter in these bits. bit 0 = rm : register file/memory selector. this bit is set and cleared by software. 0: dma transactions are with memory (see also dapr.dp) 1: dma transactions are with the register file generic external peripheral inter- rupt and dma control (idcr) read/write address set by peripheral reset value: undefined bit 5 = ip : interrupt pending . this bit is set by hardware when the trigger event occurs. it is cleared by hardware when the request is acknowledged. it can be set/cleared by software in order to generate/cancel a pending request. 0: no interrupt pending 1: interrupt pending bit 4 = dm : dma request mask . this bit is set and cleared by software. it is also cleared when the transaction counter reaches zero (unless swap mode is active). 0: no dma request is generated when ip is set. 1: dma request is generated when ip is set bit 3 = im : end of block interrupt mask . this bit is set and cleared by software. 0: no end of block interrupt request is generated when ip is set 1: end of block interrupt is generated when ip is set. dma requests depend on the dm bit value as shown in the table below. bit 2:0 = prl[2:0] : source priority level . these bits are set and cleared by software. refer to section 4.2 for a description of priority levels. dma address pointer register (dapr) read/write address set by peripheral reset value: undefined bit 7:1 = a[7:1] : dma address register(s) pointer software should write the pointer to the dma ad- dress register(s) in these bits. bit 0 = ps : memory segment pointer selector : this bit is set and cleared by software. it is only meaningful if dapr.rm=0. 0: the isr register is used to extend the address of data transferred by dma (see mmu chapter). 1: the dmasr register is used to extend the ad- dress of data transferred by dma (see mmu chapter). 70 c7 c6 c5 c4 c3 c2 c1 rm 70 ip dm im prl2 prl1 prl0 dm im meaning 10 a dma request generated without end of block interrupt when ip=1 11 a dma request generated with end of block in- terrupt when ip=1 00 no end of block interrupt or dma request is generated when ip=1 01 an end of block interrupt is generated without associated dma request (not used) prl2 prl1 prl0 source priority level 0000h ighest 0011 0102 0113 1004 1015 1106 1117lo west 70 a7 a6 a5 a4 a3 a2 a1 ps
75/224 st92163 - reset and clock control unit (rccu) 5 reset and clock control unit (rccu) 5.1 introduction the reset and clock control unit (rccu) com- prises two distinct sections: the clock control unit, which generates and manages the internal clock signals. the reset/stop manager, which detects and flags hardware, software and watchdog gener- ated resets. on st9 devices where the external stop pin is available, this circuit also detects and manages the externally triggered stop mode, during which all oscillators are frozen in order to achieve the lowest possible power consumption. 5.2 clock control unit the clock control unit generates the internal clocks for the cpu core (cpuclk) and for the on- chip peripherals (intclk). the clock control unit may be driven by an external crystal circuit, con- nected to the oscin and oscout pins, or by an external pulse generator, connected to oscin (see figure 42 and figure 44). another clock source named ck_af can be provided from the internal rc oscillator. 5.2.1 clock control unit overview as shown in figure 34, a programmable divider can divide the clock1 input clock signal by two. the resulting signal, clock2, is the reference in- put clock to the programmable phase locked loop frequency multiplier, which is capable of mul- tiplying the clock frequency by a factor of 6, 8, 10 or 14; the multiplied clock is then divided by a pro- grammable divider, by a factor of 1 to 7. by this means, the st9 can operate with cheaper, medi- um frequency (3-5 mhz) crystals, while still provid- ing a high frequency internal clock for maximum system performance; the range of available multi- plication and division factors allow a great number of operating clock frequencies to be derived from a single crystal frequency. the undivided pll clock is also available for special purposes (high-speed peripheral). for low power operation, especially in wait for in- terrupt mode, the clock multiplier unit may be turned off, whereupon the output clock signal may be programmed as clock2 divided by 16. for further power reduction, an internal rc oscillator with a frequency of 85khz (+/- 40%) is available to provide the ck_af clock internally if the external clock source is not used. during the execution of a wfi in low power mode this clock is further divid- ed by 16 to reduce power consumption (for the se- lection of this signal refer to the description the ck_af clock source in the following sections). the internal system clock, intclk, is routed to all on-chip peripherals, as well as to the programma- ble clock prescaler unit which generates the clock for the cpu core (cpuclk). the clock prescaler is programmable and can slow the cpu clock by a factor of up to 8, allowing the programmer to reduce cpu processing speed, and thus power consumption, while maintaining a high speed clock to the peripherals. this is partic- ularly useful when little actual processing is being done by the cpu and the peripherals are doing most of the work. figure 34. clock control unit simplified block diagram quartz 1/16 1/2 oscillator clock2 clock1 ck_af pll clock multiplier cpu clock prescaler to cpu core to peripherals cpuclk intclk unit /divider 1/16 rc oscillator internal
76/224 st92163 - reset and clock control unit (rccu) figure 35. st92163 clock distribution diagram 8 mhz pll 1/16 x /2 div2=0 1/2 oscillator mx1=0 mx0=1 csu_cksel=1 6 xt_div16=1 01 0 1 0 1 rccu 24 mhz intclk clock2 3-bit prescaler cpu mft 1/3 8-bit prescaler 16-bit up/down counter 1...2 56 (max intclk/3) usb interface baud rate generato r 1/n n=2...(2 16 -1) sci 16-bit down counter 1/4 wdg cpuclk embedded memory ram eprom/rom/otp i 2 c std fast 1/n 1/n n=4,6, 8...258 n=6,9,12...387 fscl 100 khz fscl 400 khz fscl > 100 khz 1...8 a/d 8-bit prescaler 1...2 56 p6.2 quartz dx2=0 dx1=0 dx0=2 (txin a/txinb) 48 mhz 01 1/16 rc oscillator 0 1 wfi and lpowfi=1 and wfi_cksel = 1 ck_af and wfi_cksel=1 or ck_st=1 and lpowfi=1 wfi internal
77/224 st92163 - reset and clock control unit (rccu) 5.3 clock management the various programmable features and operating modes of the ccu are handled by four registers: moder (mode register) this is a system register (r235, group e). the input clock divide-by-two and the cpu clock prescaler factors are handled by this register. clkctl (clock control register) this is a paged register (r240, page 55). the low power modes and the interpretation of the halt instruction are handled by this register. clk_flag (clock flag register) this is a paged register (r242, page 55). this register contains various status flags, as well as control bits for clock selection. pllconf (pll configuration register) this is a paged register (r246, page 55). the pll multiplication and division factors are programmed in this register. figure 36. clock control unit programming quartz pll 1/16 x 1/2 div2 ckaf_sel 1/n oscillator mx(1:0) 0 1 0 1 0 1 ckaf_st csu_cksel 6/8/10/14 1 0 xt_div16 dx(2:0) clock2 clock1 (moder) (clk_flag) (clkctl) (pllconf) (clk_flag) ck_af intclk to peripherals and cpu clock prescaler xtstop (clk_flag) wait for interrupt and low power modes: lpowfi (clkctl) selects low power operation automatically on entering wfi mode. wfi_cksel (clkctl) selects the ck_af clock automatically, if present, on entering wfi mode. xtstop (clk_flag) automatically stops the xtal oscillator when the ck_af clock is present and selected. outpll_2 (usb clock) 1/16 internal wfi and lpowfi=1 and wfi_cksel = 1 1 0 oscillator rc
78/224 st92163 - reset and clock control unit (rccu) clock management (cont'd) 5.3.1 pll clock multiplier programming the clock1 signal generated by the oscillator drives a programmable divide-by-two circuit. if the div2 control bit in moder is set (reset condi- tion), clock2, is equal to clock1 divided by two; if div2 is reset, clock2 is identical to clock1. a clock1 signal with a semiperiod (high or low) shorter than 40ns is forbidden if the divider by two is disabled. when the pll is active, it multiplies clock2 by 6, 8, 10 or 14, depending on the status of the mx0 -1 bits in pllconf. the multiplied clock is then di- vided by a factor in the range 1 to 7, determined by the status of the dx0-2 bits; when these bits are programmed to 111, the pll is switched off. following a reset phase, programming bits dx0-2 to a value different from 111 will turn the pll on. after allowing a stabilisation period for the pll, setting the csu_cksel bit in the clk_flag register selects the multiplier clock this peripheral contains a lock-in logic that verifies if the pll is locked to the clock2 frequency. the bit lock in clk_flag register becomes 1 when this event occurs. the maximum frequency allowed for intclk is 25mhz for 5v operation, and 12mhz for 3v opera- tion. care is required, when programming the pll multiplier and divider factors, not to exceed the maximum permissible operating frequency for intclk, according to supply voltage. the st9 being a static machine, there is no lower limit for intclk. however, below 1mhz, a/d con- verter precision (if present) decreases. 5.3.2 cpu clock prescaling the system clock, intclk, which may be the out- put of the pll clock multiplier, clock2, clock2/ 16 or ck_af, drives a programmable prescaler which generates the basic time base, cpuclk, for the instruction executer of the st9 cpu core. this allows the user to slow down program execu- tion during non processor intensive routines, thus reducing power dissipation. the internal peripherals are not affected by the cpuclk prescaler and continue to operate at the full intclk frequency. this is particularly useful when little processing is being done and the pe- ripherals are doing most of the work. the prescaler divides the input clock by the value programmed in the control bits prs2,1,0 in the moder register. if the prescaler value is zero, no prescaling takes place, thus cpuclk has the same period and phase as intclk. if the value is different from 0, the prescaling is equal to the val- ue plus one, ranging thus from two (prs2,1,0 = 1) to eight (prs2,1,0 = 7). the clock generated is shown in figure 37, and it will be noted that the prescaling of the clock does not preserve the 50% duty cycle, since the high level is stretched to replace the missing cycles. this is analogous to the introduction of wait cycles for access to external memory. when external memory wait or bus request events occur, cpu- clk is stretched at the high level for the whole pe- riod required by the function. figure 37. cpu clock prescaling 5.3.3 peripheral clock the system clock, intclk, which may be the out- put of the pll clock multiplier, clock2, clock2/ 16 or ck_af, is also routed to all st9 on-chip pe- ripherals and acts as the central timebase for all timing functions. intclk cpuclk va00260 000 001 010 011 100 101 110 111 prs value
79/224 st92163 - reset and clock control unit (rccu) clock management (cont'd) 5.3.4 low power modes the user can select an automatic slowdown of clock frequency during wait for interrupt opera- tion, thus idling in low power mode while waiting for an interrupt. in wfi operation the clock to the cpu core (cpuclk) is stopped, thus suspending program execution, while the clock to the peripher- als (intclk) may be programmed as described in the following paragraphs. an example of low power operation in wfi is illustrated in figure 38. if low power operation during wfi is disabled (lpowfi bit = 0 in the clkctl register), the cpu clk is stopped but intclk is unchanged. if low power operation during wait for interrupt is enabled (lpowfi bit = 1 in the clkctl register), as soon as the cpu executes the wfi instruction, the pll is turned off and the system clock will be forced to clock2 divided by 16, or to ck_af, if this has been selected by setting wfi_cksel, and providing ckaf_st is set, thus indicating that the internal rc oscillator is selected. if the external clock source is used, the crystal os- cillator may be stopped by setting the xtstop bit, providing that the ck_ak clock is present and se- lected, indicated by ckaf_st being set. the crys- tal oscillator will be stopped automatically on en- tering wfi if the wfi_cksel bit has been set. it should be noted that selecting a non-existent ck_af clock source is impossible, since such a selection requires that the auxiliary clock source be actually present and selected. in no event can a non-existent clock source be selected inadvert- ently. it is up to the user program to switch back to a fast- er clock on the occurrence of an interrupt, taking care to respect the oscillator and pll stabilisation delays, as appropriate.it should be noted that any of the low power modes may also be selected ex- plicitly by the user program even when not in wait for interrupt mode, by setting the appropriate bits. 5.3.5 interrupt generation system clock selection modifies the clkctl and clk_flag registers. the clock control unit generates an external inter- rupt request when ck_af and clock2/16 are selected or deselected as system clock source, as well as when the system clock restarts after a hardware stop (when the stop mode feature is available on the specific device). this interrupt can be masked by resetting the int_sel bit in the clkctl register. in the rccu the interrupt is generated with a high to low transition (see inter- rupt and dma chapters for further information). table 13. summary of operating modes using main crystal controlled oscillator mode intclk cpuclk div2 prs0-2 csu_cksel mx0-1 dx2-0 lpowfi xt_div16 pll x by 14 xtal/2 x (14/d) intclk/n 1 n-1 1 1 0 d-1 x 1 pll x by 10 xtal/2 x (10/d) intclk/n 1 n-1 1 0 0 d-1 x 1 pll x by 8 xtal/2 x (8/d) intclk/n 1 n-1 1 1 1 d-1 x 1 pll x by 6 xtal/2 x (6/d) intclk/n 1 n-1 1 0 1 d-1 x 1 slow 1 xtal/2 intclk/n 1 n-1 x x 111 x 1 slow 2 xtal/32 intclk/n 1 n-1 x x x x 0 wait for interrupt if lpowfi=0, no changes occur on intclk, but cpuclk is stopped anyway. low power wait for interrupt xtal/32 stop 1 x x x x 1 1 reset xtal/2 intclk 1 0 0 00 111 0 1 example xtal=4.4 mhz 2.2*10/2 = 11mhz 11mhz 1 0 1 00 001 x 1
80/224 st92163 - reset and clock control unit (rccu) figure 38. example of low power mode programming begin wfi_cksel 1 wfi status user's program lpowfi 1 user's program wfi end program flow comments system clock frequency interrupt quartz not divided by 2 pll multiply factor multiplier divider's factor set wait for the ck_af clock selected when wfi wait for interrupt no code is executed until interrupt served fixed to 6. to 2, and pll turned on an interrupt is requested low power mode enabled main code execution continued 8 mhz 24 mhz 8 mhz 24 mhz ** t 2 = quartz oscillator start-up time *t 1 = pll lock-in time t 1 * t 2 ** t 1 * f q =8 mhz, v cc =5 v and t=25 c rc wait dx2-0 001 xtal is selected to restart the pll quickly csu_cksel 1 pll is system clock source csu_cksel<- 1 while the ck_af is the system clock ckaf_sel <- 0 the system ck switches to xtal the pll is locked and becomes the system clock xtstop 0 to restart xtal and pll to stop pll and xtal when a wfi occurs xtstop 1 pll locking set up after reset phase: div2 = 0 xtstop = 0 mx(1:0) = 01 csu_cksel =0 interrupt wait routine (lock->1) oscillator rc oscillator
81/224 st92163 - reset and clock control unit (rccu) 5.4 clock control registers mode register (moder) r235 - read/write system register reset value: 1110 0000 (e0h) *note : this register contains bits which relate to other functions; these are described in the chapter dealing with device architecture. only those bits relating to clock functions are described here. bit 5 = div2 : oscin divided by 2 . this bit controls the divide by 2 circuit which oper- ates on the oscin clock. 0: no division of the oscin clock 1: oscin clock is internally divided by 2 bit 4:2 = prs[2:0] : clock prescaling . these bits define the prescaler value used to pres- cale cpuclk from intclk. when these three bits are reset, the cpuclk is not prescaled, and is equal to intclk; in all other cases, the internal clock is prescaled by the value of these three bits plus one. clock control register (clkctl) r240 - read write register page: 55 reset value: 0000 0000 (00h) bit 7 = int_sel : interrupt selection . 0: select the external interrupt pin as interrupt source (reset state) 1: select the internal rccu interrupt (see section 5.3.5) bit 6:4 = reserved. must be kept reset for normal operation. bit 3 = sresen : software reset enable. 0: the halt instruction turns off the quartz, the pll and the ccu 1: a reset is generated when halt is executed bit 2 = ckaf_sel : alternate function clock se- lect. 0: ck_af clock not selected 1: select ck_af clock note: to check if the selection has actually oc- curred, check that ckaf_st is set. if no ck_af clock is present, the selection will not occur. bit 1 = wfi_cksel : wfi clock select . this bit selects the clock used in low power wfi mode if lpowfi = 1. 0: intclk during wfi is clock2/16 1: intclk during wfi is ck_af, providing it is present. in effect this bit sets ckaf_sel in wfi mode warning : when the ck_af is selected as low power wfi clock but the xtal is not turned off (r242.4 = 0), after exiting from the wfi, ck_af will be still selected as system clock. in this case, reset the r240.2 bit to switch back to the xt. bit 0 = lpowfi : low power mode during wait for interrupt . 0: low power mode during wfi disabled. when wfi is executed, the cpuclk is stopped and intclk is unchanged 1: the st9 enters low power mode when the wfi instruction is executed. the clock during this state depends on wfi_cksel 70 - - div2 prs2 prs1 prs0 - - 70 int_s el --- sre- sen ckaf_s el wfi_cks el lpow fi
82/224 st92163 - reset and clock control unit (rccu) clock control registers clock flag register (clk_flag) r242 -read/write register page: 55 reset value: 0100 1000 after a watchdog reset reset value: 0010 1000 after a software reset reset value: 0000 1000 after a power-on reset warning : if this register is accessed with a logi- cal instruction, such as and or or, some bits may not be set as expected. warning: if you select the ck_af as system clock and turn off the oscillator (bits r240.2 and r242.4 at 1), and then switch back to the xt clock by resetting the r240.2 bit, you must wait for the oscillator to restart correctly (12ms). bit 7 = ex_stp : external stop flag this bit is set by hardware and cleared by soft- ware. 0: no external stop condition occurred 1: external stop condition occurred bit 6 = wdgres : watchdog reset flag. this bit is read only. 0: no watchdog reset occurred 1: watchdog reset occurred bit 5 = softres : software reset flag. this bit is read only. 0: no software reset occurred 1: software reset occurred (halt instruction) bit 4 = xtstop : external stop enable. 0: external stop disabled 1: the xtal oscillator will be stopped as soon as the ck_af clock is present and selected, whether this is done explicitly by the user pro- gram, or as a result of wfi, if wfi_cksel has previously been set to select the ck_af clock during wfi. warning: when the program writes `1' to the xtstop bit, it will still be read as 0 and is only set when the ck_af clock is running (ckaf_st=1). take care, as any operation such as a subsequent and with ` 1' or an or with ` 0' to the xtstop bit will reset it and the oscillator will not be stopped even if ckaf_st is subsequently set. bit 3 = xt_div16 : clock/16 selection this bit is set and cleared by software. an interrupt is generated when the bit is toggled. 0: clock2/16 is selected and the pll is off 1: the input is clock2 (or the pll output de- pending on the value of csu_cksel) warning: after this bit is modified from 0 to 1, take care that the pll lock-in time has elapsed be- fore setting the csu_cksel bit. bit 2 = ckaf_st : (read only) if set, indicates that the alternate function clock has been selected. if no ck_af clock signal is present on the pin, the selection will not occur. if reset, the pll clock, clock2 or clock2/16 is selected (depending on bit 0). bit 1= lock : pll locked-in this bit is read only. 0: the pll is turned off or not locked and cannot be selected as system clock source. 1: the pll is locked bit 0 = csu_cksel : csu clock select this bit is set and cleared by software. it also cleared by hardware when: bits dx[2:0] (pllconf) are set to 111; the quartz is stopped (by hardware or software); wfi is executed while the lpowfi bit is set; the xt_div16 bit (clk_flag) is forced to '0'. this prevents the pll, when not yet locked, from providing an irregular clock. furthermore, a `0' stored in this bit speeds up the pll's locking. 0: clock2 provides the system clock 1: the pll multiplier provides the system clock. note : setting the ckaf_sel bit overrides any other clock selection. resetting the xt_div16 bit overrides the csu_cksel selection 70 ex_ stp wdg res soft res xt- stop xt_ div16 ckaf_ st loc k csu_ ck- sel
83/224 st92163 - reset and clock control unit (rccu) pll configuration register (pllconf) r246 - read/write register page: 55 reset value: xx00 x111 bit 7:6 = reserved. bit 5:4 = mx[1:0] : pll multiplication factor . refer to table 14 for multiplier settings. bit 3 = reserved. bit 2:0 = dx[2:0] : pll output clock divider factor. refer to table 15 for divider settings. table 14. pll multiplication factors table 15. divider configuration figure 39. rccu general timing 70 - - mx1 mx0 - dx2 dx1 dx0 mx1 mx0 clock2 x 10 14 00 10 11 8 01 6 dx2 dx1 dx0 ck 0 0 0 pll clock/1 0 0 1 pll clock/2 0 1 0 pll clock/3 0 1 1 pll clock/4 1 0 0 pll clock/5 1 0 1 pll clock/6 1 1 0 pll clock/7 111 clock2 (pll off, reset state) stop acknowledged stop external multiplier xtal intclk internal reset clock clock reset pin pll selected by user ((n-1)*512+510)xt xtal (**) pll lock-in time pll lock-in time 4xt sys quartz start-up exit from reset 510 x t xtal (*) (*) if div2 =1 switch to pll clock (**) +/- 1 t xtal pll turned on by user xtal/2 pll pll xtal/2
84/224 st92163 - reset and clock control unit (rccu) figure 40. rccu timing during stop (ck_af system clock) figure 41. low power mode with a stopped quartz oscillator stop xtal clock pin ((n-1)*512+510) x t xtal (**) 4xt sys quartz start-up exit from stop 510 x t xtal (*) acknowledged (*) if div2 =1 rc osc clock (**) +/- 1 t xtal intclk reset ck_af selected ckaf_sel<-1 intclk wfi state multiplier clock xtal clock interrupt xtal restart time pll lock-in time t sys =2 xt xtal pll l with: div2=1 rc osc clock (t sys =t ck_af ) xtstop<-0 csu_cksel<-1 ckaf_sel<-0 pll
85/224 st92163 - reset and clock control unit (rccu) 5.5 oscillator characteristics the oscillator circuit uses an inverting gate circuit with tri-state output. notes : owing to the q factor required, ceramic resonators may not provide a reliable oscillator source . oscout must not be directly used to drive exter- nal circuits. when the oscillator is stopped, oscout goes high impedance. in halt mode, set by means of the halt instruc- tion, the parallel resistor, r, is disconnected and the oscillator is disabled, forcing the internal clock, clock1, to a high level, and oscout to a high impedance state. to exit the halt condition and restart the oscilla- tor, an external reset pulse is required. it should be noted that, if the watchdog function is enabled, a halt instruction will not disable the os- cillator. this to avoid stopping the watchdog if a halt code is executed in error. when this occurs, the cpu will be reset when the watchdog times out or when an external reset is applied. table 16. oscillator transconductance figure 42. crystal oscillator table 17. crystal internal resistance legend : c 1 ,c 2 : maximum total capacitances on pins oscin and oscout (the value includes the external capacitance tied to the pin cl1 and cl2 plus the parasitic capacitance of the board and of the device). rsmax: the equivalent serial resistor of the crystal. note 1 : the tables are relative to the fundamental quartz crystal only (not ceramic resonator). note 2 : to reduce the parasitic capacitance, it is recom- mended to place the crystal as close to the st9 mcu as possible. warning : at low temperature, frost and humidity might prevent the correct start-up of the oscillator. figure 43. internal oscillator schematic figure 44. external clock symbol voltage range min typ max unit gm 4.0-5.5v 0.77 1.5 2.4 ma/v 3.0-4.0v 0.5 0.73 1.47 oscin oscout c l1 c l2 st9 crystal clock vr02116a 1m* *recommended for oscillator stability symbol condition s c 1 =c 2 = 56pf c 1 =c 2 =47pf c 1 =c 2 = 33pf c 1 =c 2 = 22pf rsmax (ohm) 4.0-5.5v freq.=8mhz 50 w 65 w 120 w 180 w 3.0-4.0v freq.=8mhz 30 w 40 w 70 w 110 w vr02086a halt oscin oscout r in r out r clock1 oscin oscout clock input nc external clock vr02116b st9
86/224 st92163 - reset and clock control unit (rccu) 5.6 reset/stop manager the reset/stop manager resets the mcu when one of the three following events occurs: a hardware reset, initiated by a low level on the reset pin. a software reset, initiated by a halt instruction (when enabled). a watchdog end of count condition. the event which caused the last reset is flagged in the clk_flag register, by setting the sof- tres or the wdgres bits respectively; a hard- ware initiated reset will leave both these bits reset. the hardware reset overrides all other conditions and forces the st9 to the reset state. during re- set, the internal registers are set to their reset val- ues, where these are defined, and the i/o pins are set to the bidirectional weak pull-up mode. reset is asynchronous: as soon as the reset pin is driven low, a reset cycle is initiated. figure 45. oscillator start-up sequence and reset timing v dd max v dd min oscin intclk reset oscout pin 10ms vr02085a
87/224 st92163 - reset and clock control unit (rccu) reset/stop manager (cont'd) the on-chip timer/watchdog generates a reset condition if the watchdog mode is enabled (wcr.wden cleared, r252 page 0), and if the programmed period elapses without the specific code (aah, 55h) written to the appropriate register. the input pin reset is not driven low by the on- chip reset generated by the timer/watchdog. when the reset pin goes high again, a delay of 10 ms occurs before exiting the reset state (+-1 clock1 period, depending on the delay between the rising edge of the reset pin and the first rising edge of clock1). subsequently a short boot rou- tine is executed from the device internal boot rom, and control then passes to the user program. the boot routine sets the device characteristics and loads the correct values in the memory man- agement unit's pointer registers, so that these point to the physical memory areas as mapped in the specific device. the precise duration of this short boot routine varies from device to device, depending on the boot rom contents. at the end of the boot routine the program coun- ter will be set to the location specified in the reset vector located in the lowest two bytes of memory. 5.6.1 reset pin timing to improve the noise immunity of the device, the reset pin has a schmitt trigger input circuit with hysteresis. in addition, a filter will prevent an un- wanted reset in case of a single glitch of less than 50 ns on the reset pin. the device is certain to re- set if a negative pulse of more than 20 m sisap- plied. when the reset pin goes high again, a delay of up to 4 m s (at 8 mhz.) will elapse before the rccu detects this rising front. from this event on, 79870 (about 10 ms at 8 mhz.) oscillator clock cy- cles (clock1) are counted before exiting the re- set state (+-1 clock1 period depending on the delay between the positive edge the rccu de- tects and the first rising edge of clock1) if the st9 is a romless version, without on-chip program memory, the memory interface ports are set to external memory mode (i.e alternate func- tion) and the memory accesses are made to exter- nal program memory with wait cycles insertion. figure 46. recommended signal to be applied on reset pin 5.7 stop mode in stop mode, the reset/stop manager can also stop all oscillators without resetting the device. for information on entering and exiting stop mode, refer to the wake-up/interrupt lines man- agement unit (wuimu) chapter. in stop mode, all context information is preserved and the internal clock is frozen in the high state. on exiting stop mode, the mcu resumes execu- tion of the user program after a delay of 255 clock2 periods, an interrupt is generated and the ex_stp bit in clk_flag is set. v reset v cc 0.7 v cc 0.3 v cc 20 m s minimum
88/224 st92163 - reset and clock control unit (rccu) 5.8 low voltage detector (lvd) reset the on-chip low voltage detector (lvd) gener- ates a static reset when the supply voltage is be- low a reference value. the lvd works both during power-on as well as when the power supply drops (brown-out). the reference value for the voltage drop is lower than the reference value for power- on in order to avoid a parasitic reset when the mcu starts running and sinks current on the sup- ply (hysteresis). the lvd circuitry generates a reset when v dd is below: v lvdup when v dd is rising v lvdown when v dd is falling the low voltage detector circuitry resets only the mcu and it does not change the external reset pin status: no reset signal for an external applica- tion is generated. figure 47. low voltage detector reset function figure 48. low voltage detector reset signal note: refer to electrical characteristics for the values of v dd ,v lvdup and v lvddown . low voltage detector reset v dd reset internal reset (external pin) internal reset v dd v lvdup v lvddown
89/224 st92163 - external memory interface (extmi) 6 external memory interface (extmi) 6.1 introduction the st9 external memory interface uses two reg- isters (emr1 and emr2) to configure external memory accesses. some interface signals are also affected by wcr - r252 page 0. if the two registers emr1 and emr2 are set to the proper values, the st9+ memory access cycle is similar to that of the original st9, with the only ex- ception that it is composed of just two system clock phases, named t1 and t2. during phase t1, the memory address is output on the as falling edge and is valid on the rising edge of as. port0 and port 1 maintain the address sta- ble until the following t1 phase. during phase t2, two forms of behavior are possi- ble. if the memory access is a read cycle, port 0 pins are released in high-impedance until the next t1 phase and the data signals are sampled by the st9 on the rising edge of ds. if the memory ac- cess is a write cycle, on the falling edge of ds, port 0 outputs data to be written in the external memory. those data signals are valid on the rising edge of ds and are maintained stable until the next address is output. note that ds is pulled low at the beginning of phase t2 only during an exter- nal memory access. figure 49. page 21 registers n dmasr isr emr2 emr1 csr dpr3 dpr2 dpr1 dpr0 r255 r254 r253 r252 r251 r250 r249 r248 r247 r246 r245 r244 r243 r242 r241 r240 ffh feh fdh fch fbh fah f9h f8h f7h f6h f5h f4h f3h f2h f1h f0h mmu ext.mem page 21 mmu bit dprrem=0 sspl ssph uspl usph moder ppr rp1 rp0 flagr cicr p5 p4 p3 p2 p1 p0 dmasr isr emr2 emr1 csr dpr3 dpr2 dpr1 dpr0 bit dprrem=1 sspl ssph uspl usph moder ppr rp1 rp0 flagr cicr p5 p4 p3 p2 p1 p0 dmasr isr emr2 emr1 csr dpr3 dpr2 dpr1 dpr0 relocation of p[3:0] and dpr[3:0] registers
90/224 st92163 - external memory interface (extmi) 6.2 external memory signals the access to external memory is made using the as, ds, ds2, rw, port 0, port1, and wait signals described below. refer to figure 51 6.2.1 as: address strobe as (output, active low, tristate) is active during the system clock high-level phase of each t1 memory cycle: an as rising edge indicates that memory address and read/write memory control signals are valid. as is released in high-imped- ance during the bus acknowledge cycle or under the processor control by setting the himp bit (moder.0, r235). depending on the device as is available as alternate function or as a dedicated pin. under reset, as is held high with an internal weak pull-up. the behavior of this signal is affected by the mc, asaf, eto, bsz, las[1:0] and uas[1:0] bits in the emr1 or emr2 registers. refer to the regis- ter description. 6.2.2 ds: data strobe ds (output,active low, tristate) is active during the internal clock high-level phase of each t2 memory cycle. during an external memory read cycle, the data on port 0 must be valid before the ds rising edge. during an external memory write cycle, the data on port 0 are output on the falling edge of ds and they are valid on the rising edge of ds. when the internal memory is accessed ds is kept high during the whole memory cycle. ds is released in high-impedance during bus acknowledge cycle or under processor control by setting the himp bit (moder.0, r235). under reset status, ds is held high with an internal weak pull-up. the behavior of this signal is affected by the mc, ds2en, and bsz bits in the emr1 register. refer to the register description. 6.2.3 ds2: data strobe 2 this additional data strobe pin (alternate function output, active low, tristate) is available on some st9 devices only. it allows two external memories to be connected to the st9, the upper memory block (a21=1 typically ram) and the lower memo- ry block (a21=0 typically rom) without any exter- nal logic. the selection between the upper and lower memory blocks depends on the a21 address pin value. the upper memory block is controlled by the ds pin while the lower memory block is controlled by the ds2 pin. when the internal memory is ad- dressed, ds2 is kept high during the whole mem- ory cycle. ds2 is released in high-impedance dur- ing bus acknowledge cycle or under processor control by setting the himp bit (moder.0, r235). ds2 is enabled via software as the alternate func- tion output of the associated i/o port bit (refer to specific st9 version to identify the specific port and pin). the behavior of this signal is affected by the ds2en, and bsz bits in the emr1 register. refer to the register description.
91/224 st92163 - external memory interface (extmi) external memory signals (cont'd) figure 50. effects of ds2en on the behavior of ds and ds2 n ds stretch t1 t2 t1 t2 no wait cycle 1 ds wait cycle system as (mc=0) ds2en=0 or (ds2en=1 and upper memory addressed): ds2en=1 and lower memory addressed: ds ds ds ds2 (mc=1, read) (mc=1, write) (mc=0) ds ds2 (mc=0) ds2 (mc=1, read) ds2 (mc=1, write) clock
92/224 st92163 - external memory interface (extmi) external memory signals (cont'd) figure 51. external memory read/write with a programmable wait n as stretch ds stretch address address address address data in data in data out data t1 t2 t1 t2 twa twd no wait cycle 1 as wait cycle 1 ds wait cycle always read write as (mc=0) ale (mc=1) p1 ds (mc=0) p0 multiplexed rw (mc=0) ds (mc=1) rw (mc=1) p0 multiplexed rw (mc=0) ds (mc=1) rw (mc=1) address address tavqv tavwh tavwl system clock
93/224 st92163 - external memory interface (extmi) external memory signals (cont'd) 6.2.4 rw: read/write rw (alternate function output, active low, tristate) identifies the type of memory cycle: rw=o1o identifies a memory read cycle, rw=o0o identifies a memory write cycle. it is defined at the beginning of each memory cycle and it remains stable until the following memory cycle. rw is re- leased in high-impedance during bus acknowl- edge cycle or under processor control by setting the himp bit (moder). rw is enabled via soft- ware as the alternate function output of the asso- ciated i/o port bit (refer to specific st9 device to identify the port and pin). under reset status, the associated bit of the port is set into bidirectional weak pull-up mode. the behavior of this signal is affected by the mc, eto and bsz bits in the emr1 register. refer to the register description. 6.2.5 breq, back: bus request, bus acknowledge note: these pins are available only on some st9 devices (see pin description). breq (alternate function input, active low) indi- cates to the st9 that a bus request has tried or is trying to gain control of the memory bus. once en- abled by setting the brqen bit (moder.1, r235), breq is sampled with the falling edge of the processor internal clock during phase t2. n n figure 52. external memory read/write sequence with external wait (wait pin) n t1 t2 t1 t2 always read write syst em as (mc=0) ale (mc=1) ds (mc=0) p0 multiplexed rw (mc=0) ds (mc=1) rw (mc=1) p0 multiplexed rw (mc=0) ds (mc=1) rw (mc=1) wai t p1 t1 t2 address add. add. add. d.out address d.out add. data out d.in d.in d.in address address address clock
94/224 st92163 - external memory interface (extmi) external memory signals (cont'd) whenever it is sampled low, the system clock is stretched and the external memory signals (as, ds, ds2, rw, p0 and p1) are released in high-im- pedance. the external memory interface pins are driven again by the st9 as soon as breq is sam- pled high. back (alternate function output, active low) indi- cates that the st9 has relinquished control of the memory bus in response to a bus request. breq is driven low when the external memory interface signals are released in high-impedance. at mcu reset, the bus request function is disabled. to enable it, configure the i/o port pins assigned to breq and back as alternate function and set the brqen bit in the moder register. 6.2.6 port 0 if port 0 (input/output, push-pull/open-drain/ weak pull-up) is used as a bit programmable par- allel i/o port, it has the same features as a regular port. when set as an alternate function, it is used as the external memory interface: it outputs the multiplexed address 8 lsb: a[7:0] /data bus d[7:0]. 6.2.7 port 1 if port 1 (input/output, push-pull/open-drain/ weak pull-up) is used as a bit programmable par- allel i/o port, it has the same features as a regular port. when set as an alternate function, it is used as the external memory interface to provide the 8 msb of the address a[15:8]. the behavior of the port 0 and 1 pins is affected by the bsz and eto bits in the emr1 register. refer to the register description. 6.2.8 wait: external memory wait wait (alternate function input, active low) indi- cates to the st9 that the external memory requires more time to complete the memory access cycle. if bit ewen (eivr) is set, the wait signal is sam- pled with the rising edge of the processor internal clock during phase t1 or t2 of every memory cy- cle. if the signal was sampled active, one more in- ternal clock cycle is added to the memory cycle. on the rising edge of the added internal clock cy- cle, wait is sampled again to continue or finish the memory cycle stretching. note that if wait is sampled active during phase t1 then as is stretched, while if wait is sampled active during phase t2 then ds is stretched. wait is enabled via software as the alternate function input of the associated i/o port bit (refer to specific st9 ver- sion to identify the specific port and pin). under reset status, the associated bit of the port is set to the bidirectional weak pull-up mode. refer to fig- ure 52 figure 53. application example ram 64 kbytes g e a0-a15 a15-a8 st9+ ds p1 q0-q7 p0 w rw d1-d8 as oe le q1-q8 a0-a7/d0-d7 latch
95/224 st92163 - external memory interface (extmi) 6.3 register description external memory register 1 (emr1) r245 - read/write register page: 21 reset value: 1000 0000 (80h) bit 7 = reserved. bit 6 = mc : mode control . 0: as, ds and rw pins keep the st9old mean- ing. 1: as pin becomes ale, address load enable (as inverted); thus memory adress, read/ write signals are valid whenever a falling edge of ale occurs. ds becomes oen, output enable: it keeps the st9old meaning during external read opera- tions, but is forced to a1o during external write operations. rw pin becomes wen, write enable: it follows the st9old ds meaning during external write operations, but is forced to a1o during external read operations. bit 5 = ds2en : data strobe 2 enable . 0: the ds2 pin is forced to a1o during the whole memory cycle. 1: if the lower memory block is addressed, the ds2 pin follows the st9old ds meaning (if mc=0) or it becomes oen (if mc=1). the ds pin is forced to 1 during the whole memory cy- cle. if the upper memory block is used, ds2 is forced to a1o during the whole memory cycle. the ds pin behaviour is not modified. refer to figure 50 bit 4 = asaf : address strobe as alternate func- tion. depending on the device, as can be either a ded- icated pin or a port alternate function. this bit is used only in the second case. 0: as alternate function disabled. 1: as alternate function enabled. bit 2 = eto : external toggle. 0: the external memory interface pins (as, ds, ds2, rw, port0, port1) toggle only if an access to external memory is performed. 1: when the internal memory protection is dis- abled (mask option available on some devices only), the above pins (except ds and ds2 which never toggle during internal memory accesses) toggle during both internal and external memory accesses. bit 1 = bsz : bus size. 0: all the i/o ports including the external memory interface pins use smaller, less noisy output buffers. this may limit the operation frequency of the device, unless the clock is slow enough or sufficient wait states are inserted. 1: all the i/o ports including the external memory interface pins (as, ds, ds2, r/w, port 0, 1) use larger, more noisy output buffers . bit 0 = reserved. warning : external memory must be correctly addressed before and after a write operation on the emr1 register. for example, if code is fetched from external memory using the st9old external memory interface configuration (mc=0), setting the mc bit will cause the device to behave unpre- dictably. 70 x mc ds2en asaf x eto bsz x
96/224 st92163 - external memory interface (extmi) register description (cont'd) external memory register 2 (emr2) r246 - read/write register page: 21 reset value: 0000 1111 (0fh) bit 7 = reserved. bit 6 = encsr : enable code segment register. this bit affects the st9 cpu behavior whenever an interrupt request is issued. 0: the cpu works in original st9 compatibility mode concerning stack frame during interrupts. for the duration of the interrupt service routine, isr is used instead of csr, and the interrupt stack frame is identical to that of the original st9: only the pc and flags are pushed. this avoids saving the csr on the stack in the event of an interrupt, thus ensuring a faster interrupt response time. the drawback is that it is not possible for an interrupt service routine to per- form inter-segment calls or jumps: these instruc- tions would update the csr, which, in this case, is not used (isr is used instead). the code seg- ment size for all interrupt service routines is thus limited to 64k bytes. 1: if encsr is set, isr is only used to point to the interrupt vector table and to initialize the csr at the beginning of the interrupt service routine: the old csr is pushed onto the stack together with the pc and flags, and csr is then loaded with the contents of isr. in this case, iret will also re- store csr from the stack. this approach allows interrupt service routines to access the entire 4mbytes of address space; the drawback is that the interrupt response time is slightly increased, because of the need to also save csr on the stack. full compatibility with the original st9 is lost in this case, because the interrupt stack frame is different; this difference, however, should not affect the vast majority of programs. bit 5 = dprrem : data page registers remapping 0: the locations of the four mmu (memory man- agement unit) data page registers (dpr0, dpr1, dpr2 and dpr3) are in page 21. 1: the four mmu data page registers are swapped with that of the data registers of ports 0-3. refer to figure 49 bit 4 = memsel : memory selection. warning: must be set by the user when using the external memory interface (reset value is 0) . bit 3:2 = las[1:0] : lower memory address strobe stretch . these two bits contain the number of wait cycles (from 0 to 3) to add to the system clock to stretch as during external lower memory block accesses (msb of 22-bit internal address=0). the reset val- ue is 3. 70 - encsr dprrem mem sel las1 las0 uas1 uas0
97/224 st92163 - external memory interface (extmi) register description (cont'd) bit 1:0 = uas[1:0] : upper memory address strobe stretch . these two bits contain the number of wait cycles (from 0 to 3) to add to the system clock to stretch as during external upper memory block accesses (msb of 22-bit internal address=1). the reset val- ue is 3. warning : the emr2 register cannot be written during an interrupt service routine. wait control register (wcr) r252 - read/write register page: 0 reset value: 0111 1111 (7fh) bit 7 = reserved, forced by hardware to 0. bit 6 = wdgen : watchdog enable. for a description of this bit, refer to the timer/ watchdog chapter. warning : clearing this bit has the effect of set- ting the timer/watchdog to watchdog mode. un- less this is desired, it must be set to a1o. bit 5:3 = uds[2:0] : upper memory data strobe stretch. these bits contain the number of intclk cycles to be added automatically to ds for external upper memory block accesses. uds = 0 adds no addi- tional wait cycles. uds = 7 adds the maximum 7 intclk cycles (reset condition). bit 2:0 = lds[2:0] : lower memory data strobe stretch. these bits contain the number of intclk cycles to be added automatically to ds or ds2 (depend- ing on the ds2en bit of the emr1 register) for ex- ternal lower memory block accesses. lds = 0 adds no additional wait cycles, lds = 7 adds the maximum 7 intclk cycles (reset condition). note 1: the number of clock cycles added refers to intclk and not to cpuclk. note 2: the distinction between the upper memo- ry block and the lower memory block allows differ- ent wait cycles between the first 2 mbytes and the second 2 mbytes, and allows 2 different data strobe signals to be used to access 2 different memories. typically, the ram will be located above address 0x200000 and the rom below address 0x1fffff, with different access times. no extra hardware is required as ds is used to access the upper memory block and ds2 is used to access the lower memory block. warning: the reset value of the wait control register gives the maximum number of wait cy- cles for external memory. to get optimum perfor- mance from the st9, the user should write the uds[2:0] and lds[2:0] bits to 0, if the external ad- dressed memories are fast enough. 70 0 wdgen uds2 uds1 uds0 lds2 lds1 lds0
98/224 st92163 - i/o ports 7 i/o ports 7.1 introduction st9 devices feature flexible individually program- mable multifunctional input/output lines. refer to the pin description chapter for specific pin alloca- tions. these lines, which are logically grouped as 8-bit ports, can be individually programmed to pro- vide digital input/output and analog input, or to connect input/output signals to the on-chip periph- erals as alternate pin functions. all ports can be in- dividually configured as an input, bi-directional, output or alternate function. in addition, pull-ups can be turned off for open-drain operation, and weak pull-ups can be turned on in their place, to avoid the need for off-chip resistive pull-ups. ports configured as open drain must never have voltage on the port pin exceeding v dd (refer to the electri- cal characteristics section). input buffers can be either ttl or cmos compatible. alternatively some input buffers can be permanently forced by hardware to operate as schmitt triggers. 7.2 specific port configurations refer to the pin description chapter for a list of the specific port styles and reset values. 7.3 port control registers each port is associated with a data register (pxdr) and three control registers (pxc0, pxc1, pxc2). these define the port configuration and al- low dynamic configuration changes during pro- gram execution. port data and control registers are mapped into the register file as shown in fig- ure 54. port data and control registers are treated just like any other general purpose register. there are no special instructions for port manipulation: any instruction that can address a register, can ad- dress the ports. data can be directly accessed in the port register, without passing through other memory or aaccumulatoro locations. figure 54. i/o register map group e group f page 2 group f page 3 group f page 43 system registers ffh reserved p7dr p9dr r255 feh p3c2 p7c2 p9c2 r254 fdh p3c1 p7c1 p9c1 r253 fch p3c0 p7c0 p9c0 r252 fbh reserved p6dr p8dr r251 fah p2c2 p6c2 p8c2 r250 f9h p2c1 p6c1 p8c1 r249 f8h p2c0 p6c0 p8c0 r248 f7h reserved reserved reserved r247 f6h p1c2 p5c2 r246 e5h p5dr r229 f5h p1c1 p5c1 r245 e4h p4dr r228 f4h p1c0 p5c0 r244 e3h p3dr r227 f3h reserved reserved r243 e2h p2dr r226 f2h p0c2 p4c2 r242 e1h p1dr r225 f1h p0c1 p4c1 r241 e0h p0dr r224 f0h p0c0 p4c0 r240
99/224 st92163 - i/o ports port control registers (cont'd) during reset, ports with weak pull-ups are set in bidirectional/weak pull-up mode and the output data register is set to ffh. this condition is also held after reset, except for ports 0 and 1 in rom- less devices, and can be redefined under software control. bidirectional ports without weak pull-ups are set in high impedance during reset. to ensure proper levels during reset, these ports must be externally connected to either v dd or v ss through external pull-up or pull-down resistors. other reset conditions may apply in specific st9 devices. 7.4 input/output bit configuration by programming the control bits pxc0.n and pxc1.n (see figure 55) it is possible to configure bit px.n as input, output, bidirectional or alternate function output, where x is the number of the i/o port, and n the bit within the port (n = 0 to 7). when programmed as input, it is possible to select the input level as ttl or cmos compatible by pro- gramming the relevant pxc2.n control bit, except where the schmitt trigger option is assigned to the pin. the output buffer can be programmed as push- pull or open-drain. a weak pull-up configuration can be used to avoid external pull-ups when programmed as bidirec- tional (except where the weak pull-up option has been permanently disabled in the pin hardware as- signment). each pin of an i/o port may assume software pro- grammable alternate functions (refer to the de- vice pin description and to section 7.5). to output signals from the st9 peripherals, the port must be configured as af out. on st9 devices with a/d converter(s), configure the ports used for analog inputs as af in. the basic structure of the bit px.n of a general pur- pose port px is shown in figure 56. independently of the chosen configuration, when the user addresses the port as the destination reg- ister of an instruction, the port is written to and the data is transferred from the internal data bus to the output master latches. when the port is ad- dressed as the source register of an instruction, the port is read and the data (stored in the input latch) is transferred to the internal data bus. when px.n is programmed as an input : (see figure 57). the output buffer is forced tristate. the data present on the i/o pin is sampled into the input latch at the beginning of each instruc- tion execution. the data stored in the output master latch is copied into the output slave latch at the end of the execution of each instruction. thus, if bit px.n is reconfigured as an output or bidirectional, the data stored in the output slave latch will be re- flected on the i/o pin.
100/224 st92163 - i/o ports input/output bit configuration (cont'd) figure 55. control bits n table 18. port bit configuration table (n = 0, 1... 7; x = port number) (1) for a/d converter inputs. legend: x = port n = bit af = alternate function bid = bidirectional cmos= cmos standard input levels hi-z = high impedance in = input od = open drain out = output pp = push-pull ttl = ttl standard input levels wp = weak pull-up bit 7 bit n bit 0 pxc2 pxc27 pxc2n pxc20 pxc1 pxc17 pxc1n pxc10 pxc0 pxc07 pxc0n pxc00 general purpose i/o pins a/d pins pxc2n pxc1n pxc0n 0 0 0 1 0 0 0 1 0 1 1 0 0 0 1 1 0 1 0 1 1 1 1 1 1 1 1 pxn configuration bid bid out out in in af out af out af in pxn output type wp od od pp od hi-z hi-z pp od hi-z (1) pxn input type ttl (or schmitt trigger) ttl (or schmitt tr igger) ttl (or schmitt tri gger) ttl (or schmitt trigger) cmos (or schmitt tr igger) ttl (or schmitt trigger) ttl (or schmitt trigger) ttl (or schmitt trigger) analog input
101/224 st92163 - i/o ports input/output bit configuration (cont'd) figure 56. basic structure of an i/o port pin figure 57. input configuration n n figure 58. output configuration n output slave latch output master latch input latch internal data bus i/o pin push-pull tristate open drain weak pull-up from peripheral output output input bidirectional alternate function to peripheral inputs and ttl / cmos (or schmitt trigger) interrupts alternate function input output bidirectional output master latch input latch output slave latch internal data bus i/o pin tristate to peripheral inputs and ttl / cmos (or schmitt trigger) interrupts output master latch input latch output slave latch internal data bus i/o pin open drain ttl (or schmitt trigger) push-pull to peripheral inputs and interrupts
102/224 st92163 - i/o ports input/output bit configuration (cont'd) when px.n is programmed as an output : (figure 58) the output buffer is turned on in an open-drain or push-pull configuration. the data stored in the output master latch is copied both into the input latch and into the out- put slave latch, driving the i/o pin, at the end of the execution of the instruction. when px.n is programmed as bidirectional : (figure 59) the output buffer is turned on in an open-drain or weak pull-up configuration (except when dis- abled in hardware). the data present on the i/o pin is sampled into the input latch at the beginning of the execution of the instruction. the data stored in the output master latch is copied into the output slave latch, driving the i/ o pin, at the end of the execution of the instruc- tion. warning : due to the fact that in bidirectional mode the external pin is read instead of the output latch, particular care must be taken with arithme- tic/logic and boolean instructions performed on a bidirectional port pin. these instructions use a read-modify-write se- quence, and the result written in the port register depends on the logical level present on the exter- nal pin. this may bring unwanted modifications to the port output register content. for example: port register content, 0fh external port value, 03h (bits 3 and 2 are externally forced to 0) a bset instruction on bit 7 will return: port register content, 83h external port value, 83h (bits 3 and 2 have been cleared). to avoid this situation, it is suggested that all oper- ations on a port, using at least one bit in bidirec- tional mode, are performed on a copy of the port register, then transferring the result with a load in- struction to the i/o port. when px.n is programmed as a digital alter- nate function output : (figure 60) the output buffer is turned on in an open-drain or push-pull configuration. the data present on the i/o pin is sampled into the input latch at the beginning of the execution of the instruction. the signal from an on-chip function is allowed to load the output slave latch driving the i/o pin. signal timing is under control of the alternate function. if no alternate function is connected to px.n, the i/o pin is driven to a high level when in push-pull configuration, and to a high imped- ance state when in open drain configuration. figure 59. bidirectional configuration n n figure 60. alternate function configuration n n n n n n output master latch input latch output slave latch internal data bus i/o pin weak pull-up ttl (or schmitt trigger) open drain to peripheral inputs and interrupts input latch from internal data bus i/o pin open drain ttl (or schmitt trigger) push-pull peripheral output to peripheral inputs and interrupts output slave latch
103/224 st92163 - i/o ports 7.5 alternate function architecture each i/o pin may be connected to three different types of internal signal: data bus input/output alternate function input alternate function output 7.5.1 pin declared as i/o a pin declared as i/o, is connected to the i/o buff- er. this pin may be an input, an output, or a bidi- rectional i/o, depending on the value stored in (pxc2, pxc1 and pxc0). 7.5.2 pin declared as an alternate input a single pin may be directly connected to several alternate inputs. in this case, the user must select the required input mode (with the pxc2, pxc1, pxc0 bits) and enable the selected alternate function in the control register of the peripheral. no specific port configuration is required to enable an alternate function input, since the input buffer is directly connected to each alternate function module on the shared pin. as more than one mod- ule can use the same input, it is up to the user soft- ware to enable the required module as necessary. parallel i/os remain operational even when using an alternate function input. the exception to this is when an i/o port bit is permanently assigned by hardware as an a/d bit. in this case , after soft- ware programming of the bit in af-od-ttl, the al- ternate function output is forced to logic level 1. the analog voltage level on the corresponding pin is directly input to the a/d. 7.5.3 pin declared as an alternate function output the user must select the af out configuration using the pxc2, pxc1, pxc0 bits. several alter- nate function outputs may drive a common pin. in such case, the alternate function output signals are logically anded before driving the common pin. the user must therefore enable the required alternate function output by software. warning : when a pin is connected both to an al- ternate function output and to an alternate function input, it should be noted that the output signal will always be present on the alternate function input. 7.6 i/o status after wfi, halt and reset the status of the i/o ports during the wait for in- terrupt, halt and reset operational modes is shown in the following table. the external memory interface ports are shown separately. if only the in- ternal memory is being used and the ports are act- ing as i/o, the status is the same as shown for the other i/o ports. mode ext. mem - i/o ports i/o ports p0 p1, p2, p6 wfi high imped- ance or next address (de- pending on the last memory op- eration per- formed on port) next address not affected (clock outputs running) halt high imped- ance next address not affected (clock outputs stopped) reset alternate function push- pull (romless device) bidirectional weak pull-up (high im- pedance when disa- bled in hardware).
104/224 st92163 - timer/watchdog (wdt) 8 on-chip peripherals 8.1 timer/watchdog (wdt) important note: this chapter is a generic descrip- tion of the wdt peripheral. however depending on the st9 device, some or all of wdt interface signals described may not be connected to exter- nal pins. for the list of wdt pins present on the st9 device, refer to the device pinout description in the first section of the data sheet. 8.1.1 introduction the timer/watchdog (wdt) peripheral consists of a programmable 16-bit timer and an 8-bit prescal- er. it can be used, for example, to: generate periodic interrupts measure input signal pulse widths request an interrupt after a set number of events generate an output signal waveform act as a watchdog timer to monitor system in- tegrity the main wdt registers are: control register for the input, output and interrupt logic blocks (wdtcr) 16-bit counter register pair (wdthr, wdtlr) prescaler register (wdtpr) the hardware interface consists of up to five sig- nals: wdin external clock input wdout square wave or pwm signal output int0 external interrupt input nmi non-maskable interrupt input hw0sw1 hardware/software watchdog ena- ble. figure 61. timer/watchdog block diagram int0 1 input & clock control logic inen inmd1 inmd2 wdtpr 8-bit prescaler wdtrh , wdtrl 16-bit intclk/4 wdt outmd wrout output control logic interrupt control logic end of count reset top level interrupt reques t outen mux wdout 1 iaos tlis inta0 request nmi 1 wdgen hw0sw 1 1 wdin 1 mux downcou nter clock 1 pin not present on some st9 devices .
105/224 st92163 - timer/watchdog (wdt) timer/watchdog (cont'd) 8.1.2 functional description 8.1.2.1 external signals the hw0sw1 pin can be used to permanently en- able watchdog mode. refer to section 0.1.3.1. the wdin input pin can be used in one of four modes: event counter mode gated external input mode triggerable input mode retriggerable input mode the wdout output pin can be used to generate a square wave or a pulse width modulated signal. an interrupt, generated when the wdt is running as the 16-bit timer/counter, can be used as a top level interrupt or as an interrupt source connected to channel a0 of the external interrupt structure (replacing the int0 interrupt input). the counter can be driven either by an external clock, or internally by intclk divided by 4. 8.1.2.2 initialisation the prescaler (wdtpr) and counter (wdtrl, wdtrh) registers must be loaded with initial val- ues before starting the timer/counter. if this is not done, counting will start with reset values. 8.1.2.3 start/stop the st_sp bit enables downcounting. when this bit is set, the timer will start at the beginning of the following instruction. resetting this bit stops the counter. if the counter is stopped and restarted, counting will resume from the last value unless a new con- stant has been entered in the timer registers (wdtrl, wdtrh). a new constant can be written in the wdtrh, wdtrl, wdtpr registers while the counter is running. the new value of the wdtrh, wdtrl registers will be loaded at the next end of count (eoc) condition while the new value of the wdtpr register will be effective immediately. end of count is when the counter is 0. when watchdog mode is enabled the state of the st_sp bit is irrelevant. 8.1.2.4 single/continuous mode the s_c bit allows selection of single or continu- ous mode.this mode bit can be written with the timer stopped or running. it is possible to toggle the s_c bit and start the counter with the same in- struction. single mode on reaching the end of count condition, the timer stops, reloads the constant, and resets the start/ stop bit. software can check the current status by reading this bit. to restart the timer, set the start/ stop bit. note: if the timer constant has been modified dur- ing the stop period, it is reloaded at start time. continuous mode on reaching the end of count condition, the coun- ter automatically reloads the constant and restarts. it is stopped only if the start/stop bit is reset. 8.1.2.5 input section if the timer/counter input is enabled (inen bit) it can count pulses input on the wdin pin. other- wise it counts the internal clock/4. for instance, when intclk = 20mhz, the end of count rate is: 3.35 seconds for maximum count (timer const. = ffffh, prescaler const. = ffh) 200 ns for minimum count (timer const. = 0000h, prescaler const. = 00h) the input pin can be used in one of four modes: event counter mode gated external input mode triggerable input mode retriggerable input mode the mode is configurable in the wdtcr. 8.1.2.6 event counter mode in this mode the timer is driven by the external clock applied to the input pin, thus operating as an event counter. the event is defined as a high to low transition of the input signal. spacing between trailing edges should be at least 8 intclk periods (or 400ns with intclk = 20mhz). counting starts at the next input event after the st_sp bit is set and stops when the st_sp bit is reset.
106/224 st92163 - timer/watchdog (wdt) timer/watchdog (cont'd) 8.1.2.7 gated input mode this mode can be used for pulse width measure- ment. the timer is clocked by intclk/4, and is started and stopped by means of the input pin and the st_sp bit. when the input pin is high, the tim- er counts. when it is low, counting stops. the maximum input pin frequency is equivalent to intclk/8. 8.1.2.8 triggerable input mode the timer (clocked internally by intclk/4) is started by the following sequence: setting the start-stop bit, followed by a high to low transition on the input pin. to stop the timer, reset the st_sp bit. 8.1.2.9 retriggerable input mode in this mode, the timer (clocked internally by intclk/4) is started by setting the st_sp bit. a high to low transition on the input pin causes counting to restart from the initial value. when the timer is stopped (st_sp bit reset), a high to low transition of the input pin has no effect. 8.1.2.10 timer/counter output modes output modes are selected by means of the out- en (output enable) and outmd (output mode) bits of the wdtcr register. no output mode (outen = a0o) the output is disabled and the corresponding pin is set high, in order to allow other alternate func- tions to use the i/o pin. square wave output mode (outen = a1o, outmd = a0o) the timer outputs a signal with a frequency equal to half the end of count repetition rate on the wd- out pin. with an intclk frequency of 20mhz, this allows a square wave signal to be generated whose period can range from 400ns to 6.7 sec- onds. pulse width modulated output mode (outen = a1o, outmd = a1o) the state of the wrout bit is transferred to the output pin (wdout) at the end of count, and is held until the next end of count condition. the user can thus generate pwm signals by modifying the status of the wrout pin between end of count events, based on software counters decre- mented by the timer watchdog interrupt. 8.1.3 watchdog timer operation this mode is used to detect the occurrence of a software fault, usually generated by external inter- ference or by unforeseen logical conditions, which causes the application program to abandon its normal sequence of operation. the watchdog, when enabled, resets the mcu, unless the pro- gram executes the correct write sequence before expiry of the programmed time period. the appli- cation program must be designed so as to correct- ly write to the wdtlr watchdog register at regu- lar intervals during all phases of normal operation. 8.1.3.1 hardware watchdog/software watchdog the hw0sw1 pin (when available) selects hard- ware watchdog or software watchdog. if hw0sw1 is held low: the watchdog is enabled by hardware immedi- ately after an external reset. (note: software re- set or watchdog reset have no effect on the watchdog enable status). the initial counter value (ffffh) cannot be mod- ified, however software can change the prescaler value on the fly. the wdgen bit has no effect. (note: it is not forced low). if hw0sw1 is held high, or is not present: the watchdog can be enabled by resetting the wdgen bit. 8.1.3.2 starting the watchdog in watchdog mode the timer is clocked by intclk/4. if the watchdog is software enabled, the time base must be written in the timer registers before enter- ing watchdog mode by resetting the wdgen bit. once reset, this bit cannot be changed by soft- ware. if the watchdog is hardware enabled, the time base is fixed by the reset value of the registers. resetting wdgen causes the counter to start, re- gardless of the value of the start-stop bit. in watchdog mode, only the prescaler constant may be modified. if the end of count condition is reached a system reset is generated.
107/224 st92163 - timer/watchdog (wdt) timer/watchdog (cont'd) 8.1.3.3 preventing watchdog system reset in order to prevent a system reset, the sequence aah, 55h must be written to wdtlr (watchdog timer low register). once 55h has been written, the timer reloads the constant and counting re- starts from the preset value. to reload the counter, the two writing operations must be performed sequentially without inserting other instructions that modify the value of the wdtlr register between the writing operations. the maximum allowed time between two reloads of the counter depends on the watchdog timeout period. 8.1.3.4 non-stop operation in watchdog mode, a halt instruction is regarded as illegal. execution of the halt instruction stops further execution by the cpu and interrupt ac- knowledgment, but does not stop intclk, cpu- clk or the watchdog timer, which will cause a system reset when the end of count condition is reached. furthermore, st_sp, s_c and the input mode selection bits are ignored. hence, regard- less of their status, the counter always runs in continuous mode, driven by the internal clock. the output mode should not be enabled, since in this context it is meaningless. figure 62. watchdog timer mode timer start counting write wdtrh,wdtrl wd en=0 write aah,55h intowdtrl reset software fail (e.g. infiniteloop) or peripheral fail v a00220 produce count reload value count g
108/224 st92163 - timer/watchdog (wdt) timer/watchdog (cont'd) 8.1.4 wdt interrupts the timer/watchdog issues an interrupt request at every end of count, when this feature is ena- bled. a pair of control bits, ia0s (eivr.1, interrupt a0 se- lection bit) and tlis (eivr.2, top level input se- lection bit) allow the selection of 2 interrupt sources (timer/watchdog end of count, or external pin) handled in two different ways, as a top level non maskable interrupt (software reset), or as a source for channel a0 of the external interrupt logic. a block diagram of the interrupt logic is given in figure 3. note: software traps can be generated by setting the appropriate interrupt pending bit. table 1 below, shows all the possible configura- tions of interrupt/reset sources which relate to the timer/watchdog. a reset caused by the watchdog will set bit 6, wdgres of r242 - page 55 (clock flag regis- ter). see section clock control regis- ters. figure 63. interrupt sources table 19. interrupt configuration legend: wdg = watchdog function sw trap = software trap note: if ia0s and tlis = 0 (enabling the watchdog eoc as interrupt source for both top level and inta0 interrupts), only the inta0 interrupt is taken into account. timer watc hdog reset wdgen (wcr.6) inta0 request ia0s (eivr .1) mux 0 1 int0 mux 0 1 top level interrup t request va00293 tlis (eivr.2) nmi control bits enabled sources operating mode wdgen ia0s tlis reset inta0 top level 0 0 0 0 0 0 1 1 0 1 0 1 wdg/ext reset wdg/ext reset wdg/ext reset wdg/ext reset sw trap sw trap ext pin ext pin sw trap ext pin sw trap ext pin watchdog watchdog watchdog watchdog 1 1 1 1 0 0 1 1 0 1 0 1 ext reset ext reset ext reset ext reset timer timer ext pin ext pin timer ext pin timer ext pin timer timer timer timer
109/224 st92163 - timer/watchdog (wdt) timer/watchdog (cont'd) 8.1.5 register description the timer/watchdog is associated with 4 registers mapped into group f, page 0 of the register file. wdthr : timer/watchdog high register wdtlr : timer/watchdog low register wdtpr : timer/watchdog prescaler register wdtcr : timer/watchdog control register three additional control bits are mapped in the fol- lowing registers on page 0: watchdog mode enable, (wcr.6) top level interrupt selection, (eivr.2) interrupt a0 channel selection, (eivr.1) note : the registers containing these bits also con- tain other functions. only the bits relevant to the operation of the timer/watchdog are shown here. counter register this 16 bit register (wdtlr, wdthr) is used to load the 16 bit counter value. the registers can be read or written aon the flyo. timer/watchdog high register (wdthr) r248 - read/write register page: 0 reset value: 1111 1111 (ffh) bit 7:0 = r[15:8] counter most significant bits . timer/watchdog low register (wdtlr) r249 - read/write register page: 0 reset value: 1111 1111b (ffh) bit 7:0 = r[7:0] counter least significant bits. timer/watchdog prescaler register (wdtpr) r250 - read/write register page: 0 reset value: 1111 1111 (ffh) bit 7:0 = pr[7:0] prescaler value. a programmable value from 1 (00h) to 256 (ffh). warning : in order to prevent incorrect operation of the timer/watchdog, the prescaler (wdtpr) and counter (wdtrl, wdtrh) registers must be ini- tialised before starting the timer/watchdog. if this is not done, counting will start with the reset (un-in- itialised) values. watchdog timer control register (wdtcr) r251- read/write register page: 0 reset value: 0001 0010 (12h) bit 7 = st_sp : start/stop bit . this bit is set and cleared by software. 0: stop counting 1: start counting (see warning above) bit 6 = s_c : single/continuous . this bit is set and cleared by software. 0: continuous mode 1: single mode bit 5:4 = inmd[1:2] : input mode selection bits . these bits select the input mode: 70 r15 r14 r13 r12 r11 r10 r9 r8 70 r7 r6 r5 r4 r3 r2 r1 r0 70 pr7 pr6 pr5 pr4 pr3 pr2 pr1 pr0 70 st_sp s_c inmd1 inmd2 inen outmd wrout outen inmd1 inmd2 input mode 0 0 event counter 0 1 gated input (reset value) 1 0 triggerable input 1 1 retriggerable input
110/224 st92163 - timer/watchdog (wdt) timer/watchdog (cont'd) bit 3 = inen : input enable . this bit is set and cleared by software. 0: disable input section 1: enable input section bit 2 = outmd : output mode. this bit is set and cleared by software. 0: the output is toggled at every end of count 1: the value of the wrout bit is transferred to the output pin on every end of count if outen=1. bit 1 = wrout : write out . the status of this bit is transferred to the output pin when outmd is set; it is user definable to al- low pwm output (on reset wrout is set). bit 0 = outen : output enable bit . this bit is set and cleared by software. 0: disable output 1: enable output wait control register (wcr) r252 - read/write register page: 0 reset value: 0111 1111 (7fh) bit 6 = wdgen : watchdog enable (active low). resetting this bit via software enters the watch- dog mode. once reset, it cannot be set anymore by the user program. at system reset, the watch- dog mode is disabled. note: this bit is ignored if the hardware watchdog option is enabled by pin hw0sw1 (if available). external interrupt vector register (eivr) r246 - read/write register page: 0 reset value: xxxx 0110 (x6h) bit 2 = tlis : top level input selection . this bit is set and cleared by software. 0: watchdog end of count is tl interrupt source 1: nmi is tl interrupt source bit 1 = ia0s : interrupt channel a0 selection. this bit is set and cleared by software. 0: watchdog end of count is inta0 source 1: external interrupt pin is inta0 source warning : to avoid spurious interrupt requests, the ia0s bit should be accessed only when the in- terrupt logic is disabled (i.e. after the di instruc- tion). it is also necessary to clear any possible in- terrupt pending requests on channel a0 before en- abling this interrupt channel. a delay instruction (e.g. a nop instruction) must be inserted between the reset of the interrupt pending bit and the ia0s write instruction. other bits are described in the interrupt section. 70 x wdgen x x x x x x 70 x x x x x tlis ia0s x
111/224 st92163 - multifunction timer (mft) 8.2 multifunction timer (mft) 8.2.1 introduction the multifunction timer (mft) peripheral offers powerful timing capabilities and features 12 oper- ating modes, including automatic pwm generation and frequency measurement. the mft comprises a 16-bit up/down counter driven by an 8-bit programmable prescaler. the in- put clock may be intclk/3 or an external source. the timer features two 16-bit comparison regis- ters, and two 16-bit capture/load/reload regis- ters. two input pins and two alternate function out- put pins are available. several functional configurations are possible, for instance: 2 input captures on separate external lines, and 2 independent output compare functions with the counter in free-running mode, or 1 output com- pare at a fixed repetition rate. 1 input capture, 1 counter reload and 2 inde- pendent output compares. 2 alternate autoreloads and 2 independent out- put compares. 2 alternate captures on the same external line and 2 independent output compares at a fixed repetition rate. when two timers are present in an st9 device, a combined operating mode is available. an internal on-chip event signal can be used on some devices to control other on-chip peripherals. the two external inputs may be individually pro- grammed to detect any of the following: rising edges falling edges both rising and falling edges figure 64. mft simplified block diagram
112/224 st92163 - multifunction timer (mft) multifunction timer (cont'd) the configuration of each input is programmed in the input control register. each of the two output pins can be driven from any of three possible sources: compare register 0 logic compare register 1 logic overflow/underflow logic each of these three sources can cause one of the following four actions, independently, on each of the two outputs: nop, set, reset, toggle in addition, an additional on-chip event signal can be generated by two of the three sources men- tioned above, i.e. over/underflow event and com- pare 0 event. this signal can be used internally to synchronise another on-chip peripheral. five maskable interrupt sources referring to an end of count condition, 2 input captures and 2 output compares, can generate 3 different interrupt re- quests (with hardware fixed priority), pointing to 3 interrupt routine vectors. two independent dma channels are available for rapid data transfer operations. each dma request (associated with a capture on the reg0r register, or with a compare on the cmp0r register) has pri- ority over an interrupt request generated by the same source. a swap mode is also available to allow high speed continuous transfers (see interrupt and dma chapter). figure 65. detailed block diagram
113/224 st92163 - multifunction timer (mft) multifunction timer (cont'd) 8.2.2 functional description the mft operating modes are selected by pro- gramming the timer control register (tcr) and the timer mode register (tmr). 8.2.2.1 trigger events a trigger event may be generated by software (by setting either the cp0 or the cp1 bits in the t_flagr register) or by an external source which may be programmed to respond to the rising edge, the falling edge or both by programming bits a0- a1 and b0-b1 in the t_icr register. this trigger event can be used to perform a capture or a load, depending on the timer mode (configured using the bits in table 4). an event on the txina input or setting the cp0 bit triggers a capture to, or a load from the reg0r register (except in bicapture mode, see section 0.1.2.11). an event on the txinb input or setting the cp1 bit triggers a capture to, or a load from the reg1r register. in addition, in the special case of oload from reg0r and monitor on reg1ro, it is possible to use the txinb input as a trigger for reg0r.o 8.2.2.2 one shot mode when the counter generates an overflow (in up- count mode), or an underflow (in down-count mode), that is to say when an end of count condi- tion is reached, the counter stops and no counter reload occurs. the counter may only be restarted by an external trigger on txina or b or a by soft- ware trigger on cp0 only. one shot mode is en- tered by setting the co bit in tmr. 8.2.2.3 continuous mode whenever the counter reaches an end of count condition, the counting sequence is automatically restarted and the counter is reloaded from reg0r (or from reg1r, when selected in biload mode). continuous mode is entered by resetting the c0 bit in tmr. 8.2.2.4 triggered and retriggered modes a triggered event may be generated by software (by setting either the cp0 or the cp1 bit in the t_flagr register), or by an external source which may be programmed to respond to the rising edge, the falling edge or both, by programming bits a0-a1 and b0-b1 in t_icr. in one shot and triggered mode, every trigger event arriving before an end of count, is masked. in one shot and retriggered mode, every trigger received while the counter is running, automatical- ly reloads the counter from reg0r. triggered/re- triggered mode is set by the ren bit in tmr. the txina input refers to reg0r and the txinb input refers to reg1r. warning . if the triggered mode is selected when the counter is in continuous mode, every trigger is disabled, it is not therefore possible to synchronise the counting cycle by hardware or software. 8.2.2.5 gated mode in this mode, counting takes place only when the external gate input is at a logic low level. the se- lection of txina or txinb as the gate input is made by programming the in0-in3 bits in t_icr. 8.2.2.6 capture mode the reg0r and reg1r registers may be inde- pendently set in capture mode by setting rm0 or rm1 in tmr, so that a capture of the current count value can be performed either on reg0r or on reg1r, initiated by software (by setting cp0 or cp1 in the t_flagr register) or by an event on the external input pins. warning . care should be taken when two soft- ware captures are to be performed on the same register. in this case, at least one instruction must be present between the first cp0/cp1 bit set and the subsequent cp0/cp1 bit reset instructions. 8.2.2.7 up/down mode the counter can count up or down depending on the state of the udc bit (up/down count) in tcr, or on the configuration of the external input pins, which have priority over udc (see input pin as- signment in t_icr). the udcs bit returns the counter up/down current status (see also the up/ down autodiscrimination mode in the input pin assignment section).
114/224 st92163 - multifunction timer (mft) multifunction timer (cont'd) 8.2.2.8 free running mode the timer counts continuously (in up or down mode) and the counter value simply overflows or underflows through ffffh or zero; there is no end of count condition as such, and no reloading takes place. this mode is automatically selected either in bicapture mode or by setting reg0r for a capture function (continuous mode must also be set). in autoclear mode, free running operation can be had, with the possibility of choosing a max- imum count value before overflow or underflow which is less than 2 16 (see autoclear mode). 8.2.2.9 monitor mode when the rm1 bit in tmr is reset, and the timer is not in bivalue mode, reg1r acts as a monitor, duplicating the current up or down counter con- tents, thus allowing the counter to be read aon the flyo. 8.2.2.10 autoclear mode a clear command forces the counter either to 0000h or to ffffh, depending on whether up- counting or downcounting is selected. the counter reset may be obtained either directly, through the ccl bit in tcr, or by entering the autoclear mode, through the ccp0 and ccmp0 bits in tcr. every capture performed on reg0r (if ccp0 is set), or every successful compare performed by cmp0r (if ccmp0 is set), clears the counter and reloads the prescaler. the clear on capture mode allows direct meas- urement of delta time between successive cap- tures on reg0r, while the clear on compare mode allows free running with the possibility of choosing a maximum count value before overflow or underflow which is less than 2 16 (see free run- ning mode). 8.2.2.11 bivalue mode depending on the value of the rm0 bit in tmr, the biload mode (rm0 reset) or the bicapture mode (rm0 set) can be selected as illustrated in figure 1 below: table 20. bivalue modes a) biload mode the biload mode is entered by selecting the bival- ue mode (bm set in tmr) and programming reg0r as a reload register (rm0 reset in tmr). at any end of count, counter reloading is per- formed alternately from reg0r and reg1r, (a low level for bm bit always sets reg0r as the cur- rent register, so that, after a low to high transition of bm bit, the first reload is always from reg0r). tmr bits timer operating modes rm0 rm1 bm 0 1 x x 1 1 biload mode bicapture mode
115/224 st92163 - multifunction timer (mft) multifunction timer (cont'd) every software or external trigger event on reg0r performs a reload from reg0r resetting the biload cycle. in one shot mode (reload initiat- ed by software or by an external trigger), reloading is always from reg0r. b) bicapture mode the bicapture mode is entered by selecting the bi- value mode (the bm bit in tmr is set) and by pro- gramming reg0r as a capture register (the rm0 bit in tmr is set). every capture event, software simulated (by set- ting the cp0 flag) or coming directly from the txi- na input line, captures the current counter value alternately into reg0r and reg1r. when the bm bit is reset, reg0r is the current register, so that the first capture, after resetting the bm bit, is always into reg0r. 8.2.2.12 parallel mode when two timers are present on an st9 device, the parallel mode is entered when the eck bit in the tmr register of timer 1 is set. the timer 1 prescaler input is internally connected to the timer 0 prescaler output. timer 0 prescaler input is con- nected to the system clock line. by loading the prescaler register of timer 1 with the value 00h the two timers (timer 0 and timer 1) are driven by the same frequency in parallel mode. in this mode the clock frequency may be divided by a factor in the range from 1 to 2 16 . 8.2.2.13 autodiscriminator mode the phase difference sign of two overlapping puls- es (respectively on txinb and txina) generates a one step up/down count, so that the up/down con- trol and the counter clock are both external. the setting of the udc bit in the tcr register has no effect in this configuration. figure 66. parallel mode description prescaler 0 prescaler 1 timer 1 timer 0 intclk/ 3 note: timer 1 is not available on all devices. refer to (see note) block diagram and register map. the device
116/224 st92163 - multifunction timer (mft) multifunction timer (cont'd) 8.2.3 input pin assignment the two external inputs (txina and txinb) of the timer can be individually configured to catch a par- ticular external event (i.e. rising edge, falling edge, or both rising and falling edges) by programming the two relevant bits (a0, a1 and b0, b1) for each input in the external input control register (t_icr). the 16 different functional modes of the two exter- nal inputs can be selected by programming bits in0 - in3 of the t_icr, as illustrated in figure 2 table 21. input pin function some choices relating to the external input pin as- signment are defined in conjunction with the rm0 and rm1 bits in tmr. for input pin assignment codes which use the in- put pins as trigger inputs (except for code 1010, trigger up:trigger down), the following conditions apply: a trigger signal on the txina input pin performs an u/d counter load if rm0 is reset, or an exter- nal capture if rm0 is set. a trigger signal on the txinb input pin always performs an external capture on reg1r. the txinb input pin is disabled when the bivalue mode is set. note : for proper operation of the external input pins, the following must be observed: the minimum external clock/trigger pulse width must not be less than the system clock (intclk) period if the input pin is programmed as rising or falling edge sensitive. the minimum external clock/trigger pulse width must not be less than the prescaler clock period (intclk/3) if the input pin is programmed as ris- ing and falling edge sensitive (valid also in auto discrimination mode). the minimum delay between two clock/trigger pulse active edges must be greater than the prescaler clock period (intclk/3), while the minimum delay between two consecutive clock/ trigger pulses must be greater than the system clock (intclk) period. the minimum gate pulse width must be at least twice the prescaler clock period (intclk/3). in autodiscrimination mode, the minimum delay between the input pin a pulse edge and the edge of the input pin b pulse, must be at least equal to the system clock (intclk) period. if a number, n, of external pulses must be count- ed using a compare register in external clock mode, then the compare register must be load- ed with the value [x +/- (n-1)], where x is the starting counter value and the sign is chosen de- pending on whether up or down count mode is selected. i c reg. in3-in0 bits txina input function txinb input function 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 not used not used gate gate not used trigger gate trigger clock up up/down trigger up up/down autodiscr. trigger ext. clock trigger not used trigger not used trigger ext. clock not used ext. clock trigger clock down ext. clock trigger down not used autodiscr. ext. clock trigger gate
117/224 st92163 - multifunction timer (mft) multifunction timer (cont'd) 8.2.3.1 txina = i/o - txinb = i/o input pins a and b are not used by the timer. the counter clock is internally generated and the up/ down selection may be made only by software via the udc (software up/down) bit in the tcr regis- ter. 8.2.3.2 txina = i/o - txinb = trigger the signal applied to input pin b acts as a trigger signal on reg1r register. the prescaler clock is internally generated and the up/down selection may be made only by software via the udc (soft- ware up/down) bit in the tcr register. 8.2.3.3 txina = gate - txinb = i/o the signal applied to input pin a acts as a gate sig- nal for the internal clock (i.e. the counter runs only when the gate signal is at a low level). the counter clock is internally generated and the up/down con- trol may be made only by software via the udc (software up/down) bit in the tcr register. 8.2.3.4 txina = gate - txinb = trigger both input pins a and b are connected to the timer, with the resulting effect of combining the actions relating to the previously described configurations. 8.2.3.5 txina = i/o - txinb = ext. clock the signal applied to input pin b is used as the ex- ternal clock for the prescaler. the up/down selec- tion may be made only by software via the udc (software up/down) bit in the tcr register. 8.2.3.6 txina = trigger - txinb = i/o the signal applied to input pin a acts as a trigger for reg0r, initiating the action for which the reg- ister was programmed (i.e. a reload or capture). the prescaler clock is internally generated and the up/down selection may be made only by software via the udc (software up/down) bit in the tcr register. (*) the timer is in one shot mode and regor in reload mode 8.2.3.7 txina = gate - txinb = ext. clock the signal applied to input pin b, gated by the sig- nal applied to input pin a, acts as external clock for the prescaler. the up/down control may be made only by software action through the udc bit in the tcr register. 8.2.3.8 txina = trigger - txinb = trigger the signal applied to input pin a (or b) acts as trig- ger signal for reg0r (or reg1r), initiating the action for which the register has been pro- grammed. the counter clock is internally generat- ed and the up/down selection may be made only by software via the udc (software up/down) bit in the tcr register.
118/224 st92163 - multifunction timer (mft) multifunction timer (cont'd) 8.2.3.9 txina = clock up - txinb = clock down the edge received on input pin a (or b) performs a one step up (or down) count, so that the counter clock and the up/down control are external. setting the udc bit in the tcr register has no effect in this configuration, and input pin b has priority on input pin a. 8.2.3.10 txina = up/down - txinb = ext clock an high (or low) level applied to input pin a sets the counter in the up (or down) count mode, while the signal applied to input pin b is used as clock for the prescaler. setting the udc bit in the tcr reg- ister has no effect in this configuration. 8.2.3.11 txina = trigger up - txinb = trigger down up/down control is performed through both input pins a and b. a edge on input pin a sets the up count mode, while a edge on input pin b (which has priority on input pin a) sets the down count mode. the counter clock is internally generated, and setting the udc bit in the tcr register has no effect in this configuration. 8.2.3.12 txina = up/down - txinb = i/o an high (or low) level of the signal applied on in- put pin a sets the counter in the up (or down) count mode. the counter clock is internally generated. setting the udc bit in the tcr register has no ef- fect in this configuration.
119/224 st92163 - multifunction timer (mft) multifunction timer (cont'd) 8.2.3.13 autodiscrimination mode the phase between two pulses (respectively on in- put pin b and input pin a) generates a one step up (or down) count, so that the up/down control and the counter clock are both external. thus, if the ris- ing edge of txinb arrives when txina is at a low level, the timer is incremented (no action if the ris- ing edge of txinb arrives when txina is at a high level). if the falling edge of txinb arrives when txina is at a low level, the timer is decremented (no action if the falling edge of txinb arrives when txina is at a high level). setting the udc bit in the tcr register has no ef- fect in this configuration. 8.2.3.14 txina = trigger - txinb = ext. clock the signal applied to input pin a acts as a trigger signal on reg0r, initiating the action for which the register was programmed (i.e. a reload or cap- ture), while the signal applied to input pin b is used as the clock for the prescaler. (*) the timer is in one shot mode and reg0r in reload mode 8.2.3.15 txina = ext. clock - txinb = trigger the signal applied to input pin b acts as a trigger, performing a capture on reg1r, while the signal applied to input pin a is used as the clock for the prescaler. 8.2.3.16 txina = trigger - txinb = gate the signal applied to input pin a acts as a trigger signal on reg0r, initiating the action for which the register was programmed (i.e. a reload or cap- ture), while the signal applied to input pin b acts as a gate signal for the internal clock (i.e. the counter runs only when the gate signal is at a low level).
120/224 st92163 - multifunction timer (mft) multifunction timer (cont'd) 8.2.4 output pin assignment two external outputs are available when pro- grammed as alternate function outputs of the i/o pins. two registers output a control register (oacr) and output b control register (obcr) define the driver for the outputs and the actions to be per- formed. each of the two output pins can be driven from any of the three possible sources: compare register 0 event logic compare register 1 event logic overflow/underflow event logic. each of these three sources can cause one of the following four actions on any of the two outputs: nop set reset toggle furthermore an on chip event signal can be driv- en by two of the three sources: the over/under- flow event and compare 0 event by programming the cev bit of the oacr register and the oev bit of obcr register respectively. this signal can be used internally to synchronise another on-chip pe- ripheral. output waveforms depending on the programming of oacr and ob- cr, the following example waveforms can be gen- erated on txouta and txoutb pins. for a configuration where txouta is driven by the over/underflow (ouf) and the compare 0 event (cm0), and txoutb is driven by the over/under- flow and compare 1 event (cm1): oacr is programmed with txouta preset to a0o, ouf sets txouta, cm0 resets txouta and cm1 does not affect the output. obcr is programmed with txoutb preset to a0o, ouf sets txoutb, cm1 resets txoutb while cm0 does not affect the output. for a configuration where txouta is driven by the over/underflow, by compare 0 and by compare 1; txoutb is driven by both compare 0 and com- pare 1. oacr is programmed with txouta pre- set to a0o. ouf toggles output 0, as do cm0 and cm1. obcr is programmed with txoutb preset to a1o. ouf does not affect the output; cm0 resets txoutb and cm1 sets it. oacr = [101100x0] obcr = [111000x0] t0outa t0outb ouf comp1 ouf comp1 ouf comp0 ouf comp0 oacr = [010101x0] obcr = [100011x1] t0outa t0outb comp1 comp1 ouf ouf comp0 comp0 comp0 comp0 comp1 comp1
121/224 st92163 - multifunction timer (mft) multifunction timer (cont'd) for a configuration where txouta is driven by the over/underflow and by compare 0, and txoutb is driven by the over/underflow and by compare 1. oacr is programmed with txouta preset to a0o. ouf sets txouta while cm0 resets it, and cm1 has no effect. obcr is programmed with tx- outb preset to a1o. ouf toggles txoutb, cm1 sets it and cm0 has no effect. for a configuration where txouta is driven by the over/underflow and by compare 0, and txoutb is driven by compare 0 and 1. oacr is pro- grammed with txouta preset to a0o. ouf sets txouta, cm0 resets it and cm1 has no effect. obcr is programmed with txoutb preset to a0o. ouf has no effect, cm0 sets txoutb and cm1 toggles it. output waveform samples in biload mode txouta is programmed to monitor the two time intervals, t1 and t2, of the biload mode, while tx- outb is independent of the over/underflow and is driven by the different values of compare 0 and compare 1. oacr is programmed with txouta preset to a0o. ouf toggles the output and cm0 and cm1 do not affect txouta. obcr is programmed with txoutb preset to a0o. ouf has no effect, while cm1 resets txoutb and cm0 sets it. depending on the cm1/cm0 values, three differ- ent sample waveforms have been drawn based on the above mentioned configuration of obcr. in the last case, with a different programmed value of obcr, only compare 0 drives txoutb, toggling the output. note (*) depending on the cmp1r/cmp0r values oacr = [101100x0] obcr = [000111x0] t0outa t0outb ouf ouf comp0 comp0 comp0 comp0 comp1 comp1
122/224 st92163 - multifunction timer (mft) multifunction timer (cont'd) 8.2.5 interrupt and dma 8.2.5.1 timer interrupt the timer has 5 different interrupt sources, be- longing to 3 independent groups, which are as- signed to the following interrupt vectors: table 22. timer interrupt structure the three least significant bits of the vector pointer address represent the relative priority assigned to each group, where 000 represents the highest pri- ority level. these relative priorities are fixed by hardware, according to the source which gener- ates the interrupt request. the 5 most significant bits represent the general priority and are pro- grammed by the user in the interrupt vector reg- ister (t_ivr). each source can be masked by a dedicated bit in the interrupt/dma mask register (idmr) of each timer, as well as by a global mask enable bit (id- mr.7) which masks all interrupts. if an interrupt request (cm0 or cp0) is present be- fore the corresponding pending bit is reset, an overrun condition occurs. this condition is flagged in two dedicated overrun bits, relating to the comp0 and capt0 sources, in the timer flag reg- ister (t_flagr). 8.2.5.2 timer dma two independent dma channels, associated with comp0 and capt0 respectively, allow dma trans- fers from register file or memory to the comp0 register, and from the capt0 register to register file or memory). if dma is enabled, the capt0 and comp0 interrupts are generated by the corre- sponding dma end of block event. their priority is set by hardware as follows: compare 0 destination e lower priority capture 0 source e higher priority the two dma request sources are independently maskable by the cp0d and cm0d dma mask bits in the idmr register. the two dma end of block interrupts are inde- pendently enabled by the cp0i and cm0i interrupt mask bits in the idmr register. 8.2.5.3 dma pointers the 6 programmable most significant bits of the dma counter pointer register (dcpr) and of the dma address pointer register (dapr) are com- mon to both channels (comp0 and capt0). the comp0 and capt0 address pointers are mapped as a pair in the register file, as are the comp0 and capt0 dma counter pair. in order to specify either the capt0 or the comp0 pointers, according to the channel being serviced, the timer resets address bit 1 for capt0 and sets it for comp0, when the d0 bit in the dcpr regis- ter is equal to zero (word address in register file). in this case (transfers between peripheral registers and memory), the pointers are split into two groups of adjacent address and counter pairs respectively. for peripheral register to register transfers (select- ed by programming a1o into bit 0 of the dcpr reg- ister), only one pair of pointers is required, and the pointers are mapped into one group of adjacent positions. the dma address pointer register (dapr) is not used in this case, but must be considered re- served. figure 67. pointer mapping for transfers between registers and memory interrupt source vector address comp 0 comp 1 xxxx x110 capt 0 capt 1 xxxx x100 overflow/underflow xxxx x000 register file address pointers comp0 16 bit addr pointer yyyyyy11(l) yyyyyy10(h) capt0 16 bit addr pointer yyyyyy01(l) yyyyyy00(h) dma counters comp0 dma 16 bit counter xxxxxx11(l) xxxxxx10(h) capt0 dma 16 bit counter xxxxxx01(l) xxxxxx00(h)
123/224 st92163 - multifunction timer (mft) multifunction timer (cont'd) figure 68. pointer mapping for register to register transfers 8.2.5.4 dma transaction priorities each timer dma transaction is a 16-bit operation, therefore two bytes must be transferred sequen- tially, by means of two dma transfers. in order to speed up each word transfer, the second byte transfer is executed by automatically forcing the peripheral priority to the highest level (000), re- gardless of the previously set level. it is then re- stored to its original value after executing the transfer. thus, once a request is being serviced, its hardware priority is kept at the highest level re- gardless of the other timer internal sources, i.e. once a comp0 request is being serviced, it main- tains a higher priority, even if a capt0 request oc- curs between the two byte transfers. 8.2.5.5 dma swap mode after a complete data table transfer, the transac- tion counter is reset and an end of block (eob) condition occurs, the block transfer is completed. the end of block interrupt routine must at this point reload both address and counter pointers of the channel referred to by the end of block inter- rupt source, if the application requires a continu- ous high speed data flow. this procedure causes speed limitations because of the time required for the reload routine. the swap feature overcomes this drawback, al- lowing high speed continuous transfers. bit 2 of the dma counter pointer register (dcpr) and of the dma address pointer register (dapr), tog- gles after every end of block condition, alternately providing odd and even address (d2-d7) for the pair of pointers, thus pointing to an updated pair, after a block has been completely transferred. this allows the user to update or read the first block and to update the pointer values while the second is being transferred. these two toggle bits are soft- ware writable and readable, mapped in dcpr bit 2 for the cm0 channel, and in dapr bit 2 for the cp0 channel (though a dma event on a channel, in swap mode, modifies a field in dapr and dcpr common to both channels, the dapr/ dcpr content used in the transfer is always the bit related to the correct channel). swap mode can be enabled by the swen bit in the idcr register. warning : enabling swap mode affects both channels (cm0 and cp0). register file 8 bit counter xxxxxx11 compare 0 8 bit addr pointer xxxxxx10 8 bit counter xxxxxx01 capture 0 8 bit addr pointer xxxxxx00
124/224 st92163 - multifunction timer (mft) multifunction timer (cont'd) 8.2.5.6 dma end of block interrupt routine an interrupt request is generated after each block transfer (eob) and its priority is the same as that assigned in the usual interrupt request, for the two channels. as a consequence, they will be serviced only when no dma request occurs, and will be subject to a possible ouf interrupt request, which has higher priority. the following is a typical eob procedure (with swap mode enabled): test toggle bit and jump. reload pointers (odd or even depending on tog- gle bit status). reset eob bit: this bit must be reset only after the old pair of pointers has been restored, so that, if a new eob condition occurs, the next pair of pointers is ready for swapping. verify the software protection condition (see section 0.1.5.7). read the corresponding overrun bit: this con- firms that no dma request has been lost in the meantime. reset the corresponding pending bit. reenable dma with the corresponding dma mask bit (must always be done after resetting the pending bit) return. warning : the eob bits are read/write only for test purposes. writing a logical a1o by software (when the swen bit is set) will cause a spurious interrupt request. these bits are normally only re- set by software. 8.2.5.7 dma software protection a second eob condition may occur before the first eob routine is completed, this would cause a not yet updated pointer pair to be addressed, with con- sequent overwriting of memory. to prevent these errors, a protection mechanism is provided, such that the attempted setting of the eob bit before it has been reset by software will cause the dma mask on that channel to be reset (dma disabled), thus blocking any further dma operation. as shown above, this mask bit should always be checked in each eob routine, to ensure that all dma transfers are properly served. 8.2.6 register description note: in the register description on the following pages, register and page numbers are given using the example of timer 0. on devices with more than one timer, refer to the device register map for the adresses and page numbers.
125/224 st92163 - multifunction timer (mft) multifunction timer (cont'd) capture load 0 high register (reg0hr) r240 - read/write register page: 10 reset value: undefined this register is used to capture values from the up/down counter or load preset values (msb). capture load 0 low register (reg0lr) r241 - read/write register page: 10 reset value: undefined this register is used to capture values from the up/down counter or load preset values (lsb). capture load 1 high register (reg1hr) r242 - read/write register page: 10 reset value: undefined this register is used to capture values from the up/down counter or load preset values (msb). capture load 1 low register (reg1lr) r243 - read/write register page: 10 reset value: undefined this register is used to capture values from the up/down counter or load preset values (lsb). compare 0 high register (cmp0hr) r244 - read/write register page: 10 reset value: 0000 0000 (00h) this register is used to store the msb of the 16-bit value to be compared to the up/down counter content. compare 0 low register (cmp0lr) r245 - read/write register page: 10 reset value: 0000 0000 (00h) this register is used to store the lsb of the 16-bit value to be compared to the up/down counter content. compare 1 high register (cmp1hr) r246 - read/write register page: 10 reset value: 0000 0000 (00h) this register is used to store the msb of the 16-bit value to be compared to the up/down counter content. compare 1 low register (cmp1lr) r247 - read/write register page: 10 reset value: 0000 0000 (00h) this register is used to store the lsb of the 16-bit value to be compared to the up/down counter content. 70 r15 r14 r13 r12 r11 r10 r9 r8 70 r7 r6 r5 r4 r3 r2 r1 r0 70 r15 r14 r13 r12 r11 r10 r9 r8 70 r7 r6 r5 r4 r3 r2 r1 r0 70 r15 r14 r13 r12 r11 r10 r9 r8 70 r7 r6 r5 r4 r3 r2 r1 r0 70 r15 r14 r13 r12 r11 r10 r9 r8 70 r7 r6 r5 r4 r3 r2 r1 r0
126/224 st92163 - multifunction timer (mft) multifunction timer (cont'd) timer control register (tcr) r248 - read/write register page: 10 reset value: 0000 0000 (00h) bit 7 = cen : counter enable . this bit is anded with the global counter enable bit (gcen) in the cicr register (r230). the gcen bit is set after the reset cycle. 0: stop the counter and prescaler 1: start the counter and prescaler (without reload). note: even if cen=0, capture and loading will take place on a trigger event. bit 6 = ccp0 : clear on capture . 0: no effect 1: clear the counter and reload the prescaler on a reg0r or reg1r capture event bit 5 = ccmp0 : clear on compare . 0: no effect 1: clear the counter and reload the prescaler on a cmp0r compare event bit 4 = ccl : counter clear . this bit is reset by hardware after being set by software (this bit always returns a0o when read). 0: no effect 1: clear the counter without generating an inter- rupt request bit 3 = udc : up/down software selection . if the direction of the counter is not fixed by hard- ware (txina and/or txinb pins, see par. 10.3) it can be controlled by software using the udc bit. 0: down counting 1: up counting bit 2 = udcs : up/down count status . this bit is read only and indicates the direction of the counter. 0: down counting 1: up counting bit 1 = of0 : ovf/unf state . this bit is read only. 0: no overflow or underflow occurred 1: overflow or underflow occurred during a cap- ture on register 0 bit 0 = cs counter status . this bit is read only and indicates the status of the counter. 0: counter halted 1: counter running 70 cen ccp 0 ccmp 0 ccl udc udc s of0 cs
127/224 st92163 - multifunction timer (mft) multifunction timer (cont'd) timer mode register (tmr) r249 - read/write register page: 10 reset value: 0000 0000 (00h) bit 7 = oe1 : output 1 enable. 0: disable the output 1 (txoutb pin) and force it high. 1: enable the output 1 (txoutb pin) the relevant i/o bit must also be set to alternate function bit 6 = oe0 : output 0 enable. 0: disable the output 0 (txouta pin) and force it high 1: enable the output 0 (txouta pin). the relevant i/o bit must also be set to alternate function bit 5 = bm : bivalu e mode . this bit works together with the rm1 and rm0 bits to select the timer operating mode (see table 4). 0: disable bivalue mode 1: enable bivalue mode bit 4 = rm1 : reg1r mode . this bit works together with the bm and rm0 bits to select the timer operating mode. refer to table 4. note: this bit has no effect when the bivalue mode is enabled (bm=1). bit 3 = rm0 : reg0r mode . this bit works together with the bm and rm1 bits to select the timer operating mode. refer to table 4. table 23. timer operating modes bit 2 = eck timer clock control . 0: the prescaler clock source is selected depend- ing on the in0 - in3 bits in the t_icr register 1: enter parallel mode (for timer 1 and timer 3 only, no effect for timer 0 and 2). see section 0.1.2.12. bit 1 = ren : retrigger mode . 0: enable retriggerable mode 1: disable retriggerable mode bit 0 = co : continous/one shot mode . 0: continuous mode (with autoreload on end of count condition) 1: one shot mode 70 oe1 oe0 bm rm1 rm0 eck ren c0 tmr bits timer operating modes bm rm1 rm0 1 x 0 biload mode 1 x 1 bicapture mode 00 0 load from reg0r and monitor on reg1r 01 0 load from reg0r and capture on reg1r 00 1 capture on reg0r and monitor on reg1r 0 1 1 capture on reg0r and reg1r
128/224 st92163 - multifunction timer (mft) multifunction timer (cont'd) external input control register (t_icr) r250 - read/write register page: 10 reset value: 0000 0000 (00h) bit 7:4 = in[3:0] : input pin function. these bits are set and cleared by software. bit 3:2 = a[0:1] : txina pin event . these bits are set and cleared by software. bit 1:0 = b[0:1]: txinb pin event . these bits are set and cleared by software. prescaler register (prsr) r251 - read/write register page: 10 reset value: 0000 0000 (00h) this register holds the preset value for the 8-bit prescaler. the prsr content may be modified at any time, but it will be loaded into the prescaler at the following prescaler underflow, or as a conse- quence of a counter reload (either by software or upon external request). following a reset condition, the prescaler is au- tomatically loaded with 00h, so that the prescaler divides by 1 and the maximum counter clock is generated (oscin frequency divided by 6 when moder.5 = div2 bit is set). the binary value programmed in the prsr regis- ter is equal to the divider value minus one. for ex- ample, loading prsr with 24 causes the prescal- er to divide by 25. 70 in3 in2 in1 in0 a0 a1 b0 b1 in[3:0] bits txina pin function txinb input pin function 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 not used not used gate gate not used trigger gate trigger clock up up/down trigger up up/down autodiscr. trigger ext. clock trigger not used trigger not used trigger ext. clock not used ext. clock trigger clock down ext. clock trigger down not used autodiscr. ext. clock trigger gate a0 a1 txina pin event 0 0 1 1 0 1 0 1 no operation falling edge sensitive rising edge sensitive rising and falling edges b0 b1 txinb pin event 0 0 1 1 0 1 0 1 no operation falling edge sensitive rising edge sensitive rising and falling edges 70 p7 p6 p5 p4 p3 p2 p1 p0
129/224 st92163 - multifunction timer (mft) multifunction timer (cont'd) output a control register (oacr) r252 - read/write register page: 10 reset value: 0000 0000 note: whenever more than one event occurs si- multaneously, the action taken will be the result of anding the event bits xxe1-xxe0. bit 7:6 = c0e[0:1] : comp0 event bits . these bits are set and cleared by software. bit 5:4 = c1e[0:1]: comp1 event bits . these bits are set and cleared by software. bit 3:2 = oue[0:1] : ovf/unf event bits . these bits are set and cleared by software. note: whenever more than one event occurs si- multaneously, the action taken will be the result of anding the event xxe1-xxe0 bits. bit 1 = cev : on-chip event on cmp0r . this bit is set and cleared by software. 0: no action 1: a successful compare on cmp0r activates the on-chip event signal (a single pulse is generat- ed) bit 0 = op : txouta preset value . this bit is set and cleared by software and by hard- ware. the value of this bit is the preset value of the txouta pin. reading this bit returns the current state of the txouta pin (useful when it is selected in toggle mode). 70 c0e0 c0e1 c1e0 c1e1 oue0 oue1 cev 0p c0e0 c0e1 action on txouta pin on a suc- cessful compare of the cmp0r register 0 0 set 0 1 toggle 1 0 reset 1 1 nop c1e0 c1e1 action on txouta pin on a suc- cessful compare of the cmp1r reg- ister 0 0 set 0 1 toggle 1 0 reset 1 1 nop oue0 oue1 action on txouta pin on an over- flow or underflow on the u/d coun- ter 0 0 set 0 1 toggle 1 0 reset 1 1 nop
130/224 st92163 - multifunction timer (mft) multifunction timer (cont'd) output b control register (obcr) r253 - read/write register page: 10 reset value: 0000 0000 (00h) note: whenever more than one event occurs si- multaneously, the action taken will be the result of anding the event bits xxe1-xxe0. bit 7:6 = c0e[0:1] : comp0 event bits . these bits are set and cleared by software. bit 5:4 = c1e[0:1]: comp1 event bits . these bits are set and cleared by software. bit 3:2 = oue[0:1] : ovf/unf event bits . these bits are set and cleared by software. bit 1 = oev : on-chip event on ovf/unf . this bit is set and cleared by software. 0: no action 1: an underflow/overflow activates the on-chip event signal (a single pulse is generated) bit 0 = op : txoutb preset value . this bit is set and cleared by software and by hard- ware. the value of this bit is the preset value of the txoutb pin. reading this bit returns the current state of the txoutb pin (useful when it is selected in toggle mode). 70 c0e0 c0e1 c1e0 c1e1 oue0 oue1 oev 0p c0e0 c0e1 action on txoutb pin on a suc- cessful compare of the cmp0r register 0 0 set 0 1 toggle 1 0 reset 1 1 nop c1e0 c1e1 action on txoutb pin on a suc- cessful compare of the cmp1r reg- ister 0 0 set 0 1 toggle 1 0 reset 1 1 nop oue0 oue1 action on txoutb pin on an over- flow or underflow on the u/d coun- ter 0 0 set 0 1 toggle 1 0 reset 1 1 nop
131/224 st92163 - multifunction timer (mft) multifunction timer (cont'd) flag register (t_flagr) r254 - read/write register page: 10 reset value: 0000 0000 (00h) bit 7 = cp0 : capture 0 flag. this bit is set by hardware after a capture on reg0r register. an interrupt is generated de- pending on the value of the gtien, cp0i bits in the idmr register and the a0 bit in the t_flagr register. the cp0 bit must be cleared by software. setting by software acts as a software load/cap- ture to/from the reg0r register. 0: no capture 0 event 1: capture 0 event occurred bit 6 = cp1 : capture 1 flag . this bit is set by hardware after a capture on reg1r register. an interrupt is generated de- pending on the value of the gtien, cp0i bits in the idmr register and the a0 bit in the t_flagr register. the cp1 bit must be cleared by software. setting by software acts as a capture event on the reg1r register, except when in bicapture mode. 0: no capture 1 event 1: capture 1 event occurred bit 5 = cm0 : compare 0 flag . this bit is set by hardware after a successful com- pare on the cmp0r register. an interrupt is gener- ated if the gtien and cm0i bits in the idmr reg- ister are set. the cm0 bit is cleared by software. 0: no compare 0 event 1: compare 0 event occurred bit 4 = cm1 : compare 1 flag. this bit is set after a successful compare on cmp1r register. an interrupt is generated if the gtien and cm1i bits in the idmr register are set. the cm1 bit is cleared by software. 0: no compare 1 event 1: compare 1 event occurred bit 3 = ouf : overflow/underflow . this bit is set by hardware after a counter over/ underflow condition. an interrupt is generated if gtien and oui=1 in the idmr register. the ouf bit is cleared by software. 0: no counter overflow/underflow 1: counter overflow/underflow bit 2 = ocp0 : overrun on capture 0. this bit is set by hardware when more than one int/dma requests occur before the cp0 flag is cleared by software or whenever a capture is sim- ulated by setting the cp0 flag by software. the ocp0 flag is cleared by software. 0: no capture 0 overrun 1: capture 0 overrun bit 1 = ocm0 : overrun on compare 0. this bit is set by hardware when more than one int/dma requests occur before the cm0 flag is cleared by software.the ocm0 flag is cleared by software. 0: no compare 0 overrun 1: compare 0 overrun bit 0 = a0 : capture interrupt function . this bit is set and cleared by software. 0: configure the capture interrupt as an or func- tion of reg0r/reg1r captures 1: configure the capture interrupt as an and func- tion of reg0r/reg1r captures 70 cp0 cp1 cm0 cm1 ouf ocp 0 ocm 0 a0
132/224 st92163 - multifunction timer (mft) multifunction timer (cont'd) interrupt/dma mask register (idmr) r255 - read/write register page: 10 reset value: 0000 0000 (00h) bit 7 = gtien : global timer interrupt enable . this bit is set and cleared by software. 0: disable all timer interrupts 1: enable all timer timer interrupts from enabled sources bit 6 = cp0d : capture 0 dma mask. this bit is set by software to enable a capt0 dma transfer and cleared by hardware at the end of the block transfer. 0: disable capture on reg0r dma 1: enable capture on reg0r dma bit 5 = cp0i : capture 0 interrupt mask . 0: disable capture on reg0r interrupt 1: enable capture on reg0r interrupt (or capt0 dma end of block interrupt if cp0d=1) bit 4 = cp1i : capture 1 interrupt mask . this bit is set and cleared by software. 0: disable capture on reg1r interrupt 1: enable capture on reg1r interrupt bit 3 = cm0d : compare 0 dma mask. this bit is set by software to enable a comp0 dma transfer and cleared by hardware at the end of the block transfer. 0: disable compare on cmp0r dma 1: enable compare on cmp0r dma bit 2 = cm0i : compare 0 interrupt mask . this bit is set and cleared by software. 0: disable compare on cmp0r interrupt 1: enable compare on cmp0r interrupt (or comp0 dma end of block interrupt if cm0d=1) bit 1 = cm1i : compare 1 interrupt mask . this bit is set and cleared by software. 0: disable compare on cmp1r interrupt 1: enable compare on cmp1r interrupt bit 0 = oui : overflow/underflow interrupt mask . this bit is set and cleared by software. 0: disable overflow/underflow interrupt 1: enable overflow/underflow interrupt dma counter pointer register (dcpr) r240 - read/write register page: 9 reset value: undefined bit 7:2 = dcp[7:2] : msbs of dma counter register address. these are the most significant bits of the dma counter register address programmable by soft- ware. the dcp2 bit may also be toggled by hard- ware if the timer dma section for the compare 0 channel is configured in swap mode. bit 1 = dma-srce : dma source selection. this bit is set and cleared by hardware. 0: dma source is a capture on reg0r register 1: dma destination is a compare on cmp0r reg- ister bit 0 = reg/mem : dma area selection . this bit is set and cleared by software. it selects the source and destination of the dma area 0: dma from/to memory 1: dma from/to register file 70 gt- ien cp0d cp0i cp1i cm0 d cm0i cm1i oui 70 dcp7 dcp6 dcp5 dcp4 dcp3 dcp2 dma srce reg/ mem
133/224 st92163 - multifunction timer (mft) multifunction timer (cont'd) dma address pointer register (dapr) r241 - read/write register page: 9 reset value: undefined bit 7:2 = dap[7:2] : msb of dma address register location. these are the most significant bits of the dma ad- dress register location programmable by software. the dap2 bit may also be toggled by hardware if the timer dma section for the compare 0 channel is configured in swap mode. note: during a dma transfer with the register file, the dapr is not used; however, in swap mode, dapr(2) is used to point to the correct ta- ble. bit 1 = dma-srce : dma source selection. this bit is fixed by hardware. 0: dma source is a capture on reg0r register 1: dma destination is a compare on the cmp0r register bit 0 = prg/dat: dma memory selection . this bit is set and cleared by software. it is only meaningful if dcpr.reg/mem=0. 0: the isr register is used to extend the address of data transferred by dma (see mmu chapter). 1: the dmasr register is used to extend the ad- dress of data transferred by dma (see mmu chapter). interrupt vector register (t_ivr) r242 - read/write register page: 9 reset value: xxxx xxx0 this register is used as a vector, pointing to the 16-bit interrupt vectors in memory which contain the starting addresses of the three interrupt sub- routines managed by each timer. only one interrupt vector register is available for each timer, and it is able to manage three interrupt groups, because the 3 least significant bits are fixed by hardware depending on the group which generated the interrupt request. in order to determine which request generated the interrupt within a group, the t_flagr register can be used to check the relevant interrupt source. bit 7:3 = v[4:0]: msb of the vector address. these bits are user programmable and contain the five most significant bits of the timer interrupt vec- tor addresses in memory. in any case, an 8-bit ad- dress can be used to indicate the timer interrupt vector locations, because they are within the first 256 memory locations (see interrupt and dma chapters). bit 2:1 = w[1:0]: vector address bits. these bits are equivalent to bit 1 and bit 2 of the timer interrupt vector addresses in memory. they are fixed by hardware, depending on the group of sources which generated the interrupt request as follows:. bit 0 = this bit is forced by hardware to 0. 70 dap 7 dap 6 dap5 dap4 dap3 dap2 dma srce prg /dat reg/mem prg/dat dma source/destination 0 0 1 1 0 1 0 1 isr register used to address memory dmasr register used to address memory register file register file 70 v4 v3 v2 v1 v0 w1 w0 0 w1 w0 interrupt source 0 0 1 1 0 1 0 1 overflow/underflow even interrupt not available capture event interrupt compare event interrupt
134/224 st92163 - multifunction timer (mft) multifunction timer (cont'd) interrupt/dma control register (idcr) r243 - read/write register page: 9 reset value: 1100 0111 (c7h) bit 7 = cpe : capture 0 eob . this bit is set by hardware when the end of block condition is reached during a capture 0 dma op- eration with the swap mode enabled. when swap mode is disabled (swen bit = a0o), the cpe bit is forced to 1 by hardware. 0: no end of block condition 1: capture 0 end of block bit 6 = cme : compare 0 eob . this bit is set by hardware when the end of block condition is reached during a compare 0 dma op- eration with the swap mode enabled. when the swap mode is disabled (swen bit = a0o), the cme bit is forced to 1 by hardware. 0: no end of block condition 1: compare 0 end of block bit 5 = dcts : dma capture transfer source . this bit is set and cleared by software. it selects the source of the dma operation related to the channel associated with the capture 0. note: the i/o port source is available only on spe- cific devices. 0: reg0r register 1: i/o port. bit 4 = dctd : dma compare transfer destination . this bit is set and cleared by software. it selects the destination of the dma operation related to the channel associated with compare 0. note: the i/o port destination is available only on specific devices. 0: cmp0r register 1: i/o port bit 3 = swen : swap function enable . this bit is set and cleared by software. 0: disable swap mode 1: enable swap mode for both dma channels. bit 2:0 = pl[2:0]: interrupt/dma priority level . with these three bits it is possible to select the in- terrupt and dma priority level of each timer, as one of eight levels (see interrupt/dma chapter). i/o connection register (iocr) r248 - read/write register page: 9 reset value: 1111 1100 (fch) bit 7:2 = not used. bit 1 = sc1 : select connection odd. this bit is set and cleared by software. it selects if the txouta and txina pins for timer 1 and timer 3 are connected on-chip or not. 0: t1outa / t1ina and t3outa/ t3ina uncon- nected 1: t1outa connected internally to t1ina and t3outa connected internally to t3ina bit 0 = sc0 : select connection even. this bit is set and cleared by software. it selects if the txouta and txina pins for timer 0 and timer 2 are connected on-chip or not. 0: t0outa / t0ina and t2outa/ t2ina uncon- nected 1: t0outa connected internally to t0ina and t2outa connected internally to t2ina note: timer 1 and 2 are available only on some devices. refer to the device block diagram and register map. 70 cpe cme dcts dct d swe n pl2 pl1 pl0 70 sc1 sc0
135/224 st92163 - usb peripheral (usb) 8.3 usb peripheral (usb) 8.3.1 introduction the usb peripheral provides a full-speed function interface between the usb bus and the st9 mi- crocontroller. 8.3.2 main features n usb specification version 1.1 compliant n supports 8 device addresses n 16 software configurable endpoints supporting: ? all usb transfer types (control, interrupt, bulk , and isochronous) ? burst-dma transfers to up to 1k bytes ram buffers n usb suspend/resume operations n on-chip 3.3v regulator n on-chip usb transceiver n special functions on alternate output pins: ? usb upstream port output enable signal (usboe) ? start-of-frame pulse (sofp) n two bit-mirror registers 8.3.3 functional description the usb interface is composed of the following blocks (see figure 69) n sie (serial interface engine): implementing usb protocol layer (for a detailed description of usb protocol refer to chapter 7, 8 of the auniversal serial bus specificationo). the functions of this block include: synchronisation pattern recognition, bit-stuffing, crc generation and checking, pid verification/generation and handshake evaluation. it must interface with usb bus on one side and with the st9 core on the other side. n st9 interface: this block is connected between the sie and the st9 microcontroller. its purpose is to handle specific endpoint registers and provide interrupt and dma servicing to the sie. the unit transfers data from or to the memory, and uses the register file to save/load pointer and counter values without cpu intervention, taking control of the st9 buses (burst-dma interface). the st9 interface unit uses interrupts to require attention from the microcontroller at the end of data transmission/ reception, and to flag error conditions. n port interface: this block contains the logic related to the usb physical port. the port interface also handles the resume detection. n frame timer: its function is to monitor the start- of-frame (sof) timing points. it detects a global suspend (from the host) when no usb traffic has been seen for 3 ms. it also generates the sofp output for any external device requiring start-of-frame synchronization. n port transceiver: containing differential and single-ended receivers and slew rate controlled output buffers. figure 69. block diagram full-speed dp0 dm0 sof timer sie endpoint logic and dma controller registers st9 bus burst usboe sofp + 3.3 v transceiver regulator interface port interrupt controller wuimu lp_susp wkup15
136/224 st92163 - usb peripheral (usb) usb interface ( cont'd ) 8.3.3.1 dma transfer dma descriptors for each endpoint, located in the st9 register file, indicate where the related mem- ory buffer is located in ram, how large the allocat- ed buffer is and how many bytes must be transmit- ted. when a data transfer takes place, the usb-fs buffering data loaded in an internal 8 byte long fifo buffer, and performing burst-dma transfers as appropriate. then, if needed, the proper hand- shake answer is generated or expected, according to the direction of the transfer. at the end of the transaction, an interrupt is generated: using status registers and different interrupt vectors, the micro- controller can determine which endpoint was served, which type of transaction took place, if er- rors occurred (bit stuffing, format, crc, protocol, missing ack, over/underrun, etc...). 8.3.3.2 structure and usage of dma buffers each endpoint has two dma buffers (one for trans- mission and the other for reception) whose size may be up to 1023 bytes each. they can be placed anywhere in memory (internally or exter- nally). for each endpoint, eight register file locations are used: addrn_th and addrn_tl : these registers point to the starting address of the memory buffer containing the data to be transmitted by endpoint n at the next in token addressed to it. countn_tl and countn_th : these registers contain the number of bytes to be transmitted by endpoint n at the next in token addressed to it. addrn_rl and addrn_rh : these registers point to the starting address of the memory buffer which will contain the data received by endpoint n at the next out/setup token addressed to it. countn_rl and countn_rh: these registers contain the allocated buffer size for endpoint n re- ception, setting the maximum number of bytes the related endpoint can receive with the next out/ setup transaction. other register locations related to unsupported transfer directions or unused endpoints, are avail- able to the user. isochronous endpoints have a special way of handling dma buffers. the relationship between register file locations and memory buffer areas is depicted in figure 70. each dma buffer is used starting from the bottom, either during reception or transmission. the usb interface never changes the contents of memory locations adjacent to the dma memory buffers; even if a packet bigger than the allocated buffer length is received (buffer overrun condition) the data will be copied in memory only up to the last available location.
137/224 st92163 - usb peripheral (usb) figure 70. dma buffers and related register file locations 8.3.3.3 interrupt modes two interrupt modes are available: single vector, where the application software has to poll the usb registers to determine which event required its at- tention, and multi-vector, where a specific interrupt vector is used for each endpoint. special support is offered to isochronous transfers, implementing a swapped dma buffer usage. 8.3.3.4 suspend mode the unit can be placed in low-power mode (sus- pend mode), by writing in a control register. at this time, all static power dissipation is avoided, except for the generation of the 3.3v supply for the external pull-up resistor. the detection of activity at the usb inputs while in low-power mode wakes the device up asynchronously. a special interrupt source, esusp, is connected directly to a wake- up line so as to allow the st9 to exit from halt condition. addr0_th addr0_tl r0 count0_th count0_tl addr0_rh addr0_rl count0_rh count0_rl addr1_th addr1_tl count1_th count1_tl addr1_rh addr1_rl count1_rh count1_rl r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15 addr2_th addr2_tl r16 r17 register file locations transmission buffer for endpoint 0 reception buffer for endpoint 0 transmission buffer for endpoint 1 memory area register file
138/224 st92163 - usb peripheral (usb) usb interface ( cont'd ) 8.3.4 register description usb registers can be divided into three groups: common registers (page 15): interrupt registers and usb control registers. function and endpoint registers (pages 15, 4 and 5 depending on how many endpoints are im- plemented): usb function addresses and end- point status/configurations. extra registers (page 60): device configuration. 8.3.4.1 common registers these registers affect all endpoints in the usb in- terface. they are all mapped in the same st9 reg- ister page (page number 15). the usb interface implements vectorized inter- rupts: through a vector table it is possible to auto- matically identify the starting address of each in- terrupt service routine. the vector table contains the 16-bit addresses pointing to each of the inter- rupt service routines related to the ctr interrupt for each endpoint. other two 8-bit locations are used to store the address of the service routine handling the interrupts described in the usbistr register. when an interrupt request is acknowl- edged, the usbivr register provides a vector pointing to the location in the vector table, contain- ing the start address of the interrupt service rou- tine related to the serviced interrupt. interrupt vector register (usbivr) r248 - read/write register page: 15 reset value: xxxx xxx0 (xxh) this register may be used in two different ways de- pending on the value of the sdnav bit in the ctrl register. if sdnav bit = 1, bits 7:1 are user programmable (bit 0 is fixed to 0). the software writes the ad- dress of a vector pointing to a single interrupt routine. the application program has to select the routine related to the pending interrupts using the usbistr and ctrinf registers. if sdnav = 0, this register is used as a vector pointing to the 16-bit interrupt vectors in program memory containing the start addresses of the in- terrupt service routines related to the occurred interrupt. if several interrupts are simultaneously pending, hardware writes in this register the in- terrupt routine address related to the highest pri- ority pending interrupt. in this case the meaning of each bit is: bits 7:6 = a[1:0]: vector table address. these two bits are user programmable and they contain the two most significant bits of the interrupt vector table. this allows the user to define the in- terrupt vector table position inside the first 256 lo- cations of program memory at 64 bytes boundary. bit 5 = ctro : correct transfer interrupt occurred . 0: ctr interrupt pending 1: one of the interrupt flags in the usbistr regis- ter is pending note: if several interrupts are simultaneously pending, hardware writes this bit according to their relative priorities as listed below starting from the highest priority one to the lowest priority one: dma over/underrun (see table 24 and usbis- tr register description) correct transfer on isochronous endpoints (see epnra register description) correct transfer on non-isochronous endpoints (see epnra register description) notification events (see table 24 and usbistr register description). bits 4:1 = v[3:1] : endpoint vector . if ctro = 1, these bits are written by hardware to specify the endpoint identifier which has generat- ed the ctr interrupt request. if several ctr interrupts are pending, hardware writes the endpoint identifier related to the end- point with the highest priority. endpoint priority is defined according to the following rule: endpoint 0 has the highest priority, then endpoint 1 follows and so on up to the highest endpoint register pair (ep15) with the lowest priority. if ctro = 0, these bits are fixed to 1. in this case only one interrupt vector is used for all the inter- rupts defined in the usbistr register. 70 a1 a0 ctro v3 v2 v1 v0 0
139/224 st92163 - usb peripheral (usb) usb interface ( cont'd ) bit 0 = reserved. this bit is fixed by hardware at 0. interrupt status register (usbistr) r249 - read/write register page: 15 reset value: 0000 0000 (00h) each bit is set by hardware when the related event occurs. if one of these bits is set, the hardware clears the ctro bit and sets the v[3:0] bits in the usbivr register. in this way the usbivr register will point to the interrupt vector containing the address of the service routine related to these interrupt sourc- es. if several bits are set only a single interrupt will be generated. note: to avoid spurious clearing of some bits, it is recommended to clear them with a load instruction where all bits which must not be altered are set to 1, and all bits to be cleared are set to 0. read- modify-write instructions like and, xor,... are to be avoided: consider the case of clearing bit 0 of usbistr with an and instruction, when only bit 7 of usbistr is at 1 and the others at 0. first the microcontroller reads the content of usbistr (=10h), then it clears bit 7 and writes the result (=00h) in usbistr. if between the read and the write operations another bit were set by hardware (e.g. bit 5), writing 00h would clear it before the mi- croprocessor has the time to service the event. table 24. classification of interrupt sources: bit 7 = reserved. this bit is fixed by hardware at 0. bit 6 = dovr : dma over/underrun . st9 processor has not been able to answer a dma request in time and the usb fifo buffer is full or empty depending on the transfer direction (reception or transmission). the usb handles this event in the following way: during reception the ack handshake packet is not sent, during transmission a bit-stuffing error is forced on the transmitted stream. in both cases the host will retry the transaction. the dovr inter- rupt should never occur during normal operations. bit 5 = err : error . one of the errors listed below has occurred: nans : no answer. the timeout for a host re- sponse has expired. crc : crc error. one of the received crcs, ei- ther in the token or in the data, was wrong. bst : bit stuffing error. a bit stuffing error was detected anywhere in the pid, data, and/or crc. fvio : framing format violation. a nonstandard frame was received (eop not in the right place, wrong token sequence, etc.). bufovr : buffer overrun. a packet longer than the allocated dma buffer has been received. 70 0 dovr err esusp susp reset sof esof interrupt class dovr dma over/underrun event err notification event esusp notification event susp notification event reset notification event sof notification event esof notification event
140/224 st92163 - usb peripheral (usb) usb interface ( cont'd ) bit 4 = esusp : end suspend mode . 0: no activity detected during suspend mode 1: usb activity is detected that wakes up the usb interface during suspend mode. note: this event asynchronously clears the lp_susp bit in the usbctlr register and acti- vates the wkup15 internal wake-up line to notify the wuimu (if stop_ck_en=1 in the devconf1 register) bit 3 = susp suspend mode request . 0: no suspend mode request 1: no usb traffic has been received for 3 ms. note: the suspend condition check is enabled im- mediately after any usb reset and is disabled by hardware when suspend mode is active (lp_susp = 1) until the end of resume sequence. bit 2 = reset : usb reset request . 0: no usb reset received. 1: usb reset received. note: device address and endpoint registers are reset by an usb reset. bit 1 = sof : start of frame . 0: no sof packet received. 1: sof packet received. bit 0 = esof : expected start of frame . 0: no sof packet missed 1: sof packet is expected but not received. interrupt mask register (usbimr) r250 - read/write register page: 15 reset value: 0000 0000 (00h) this register contains mask bits for all interrupt condition bits included in the usbistr register. whenever one of the usbimr bits is 1, if the cor- responding usbistr bit is 1, an interrupt request is generated. for an explanation of each bit, refer to the usbistr register description. interrupt priority register (usbipr) r251- read/write register page: 15 reset value: 0xxx 0xxx (xxh) bit 7 = iee: isochronous endpoint enable . set by software to enable isochronous endpoints. this also enables ctr interrupts related to iso- chronous endpoints and dma overrun interrupts. 0: isochronous endpoints disabled 1: isochronous endpoints enabled bits 6:4 = piece[2:0]: priority level on iso- chronous endpoint and dma over/underrun . set by software to define the priority level of the is- ochronous endpoint ctr events (0 is the highest priority). bit 3 = niee : non-isochronous endpoint enable . set by software to enable non-isochronous end- points. this also enables ctr interrupts related to non-isochronous (bulk, control, interrupt) end- points. 0: non-isochronous endpoints disabled 1: non-isochronous endpoints enabled bits 2:0 = pnien[2:0]: priority level of non iso- chronous endpoints and notification. set by software to define the priority level of non- isochronous endpoint (bulk, control, interrupt) ctr events. 0 is the highest priority. 70 0 dovr m err m esusp m susp m reset m sof m esof m 70 iee piece 2 piece 1 piece 0 niee pnien 2 pnien 1 pnien 0
141/224 st92163 - usb peripheral (usb) usb interface ( cont'd ) interrupt sources are classified according to the following table control register (usbctlr) r252 - read/write register page: 15 reset value: 0001 0101 (15h) bit 7 = reserved. this bit is fixed by hardware at 0. bit 6 = tim_susp : timed suspend . set by software when the susp interrupt is re- ceived to enter atimed-suspendo state. 0: timed suspend inactive 1: timed suspend active. the usb interface oper- ates as in suspend mode but clocks and static power dissipation in the analog transceiver are not stopped. bit 5 = reserved. bit 4 = sdnav: single/multiple vector selection . this bit is set by software to select the single or multiple interrupt vector mode . 0: multiple interrupt vector mode 1: single interrupt vector mode see usbivr register description for detailed infor- mation. bit 3 = resume : resume request . set by software to send a resume signal to the host. 0: resume signal not forced on usb data lines. 1: resume signal forced on usb data lines. bit 2 = pdwn : power down . set by software to turn off the 3.3v on-chip voltage regulator that supplies the external pull-up resistor and the transceiver. note: as a consequence the voltage on both usb root port signal lines will drift to 0v because of the pull-down resistors in the upstream usb host or hub, generating a disconnect indication. at least 2 m s are required until the 3.3v supply falls within specifications after this bit is cleared, depending on the value of the external bypass capacitor. bit 1 = lp_susp : low-power suspend . set by software to put the usb interface in alow- power suspendo state. this condition should be entered while in atimed suspendo state (tim_susp=1). 0: low-power suspend inactive 1: low-power suspend active bit 0 = fres : force usb reset . set by software to force a reset of the usb inter- face, just like a reset signal on the usb. the usb interface is held in reset state until soft- ware clears this bit, and a ausb-reseto interrupt is generated, if enabled. 0: reset not forced 1: usb interface reset forced 70 0 tim_ susp 0 sdnav resume pdwn lp_ susp fres
142/224 st92163 - usb peripheral (usb) usb interface ( cont'd ) ctr interrupt flags (ctrinf) r253 - read/write register page: 15 reset value: 00xx xxx0 (xxh) note: this register is used only when the sdnav bit is 1. bit 7:6 = reserved. these bits are fixed by hard- ware at 0 . bit 5 = into : interrupt occurred . set by hardware when sdnav = 1 in the same way as the ctro bit in usbivr register is set when sdnav = 0. bit 4:1 = enid[3:0] : endpoint identifier . set by hardware when sdnav = 1 in the same way as v[3:0] bits in usbivr register are set when sdnav = 0. bit 0 = reserved. this bit is fixed by hardware at 0 . frame number register high (fnrh) r254 - read-only register page: 15 reset value: 0000 0xxx (0xh) bit 7 = rxdp . set/cleared by hardware to indicate d+ upstream port data line status. bit 6 = rxdm . set/cleared by hardware to indicate d- upstream port data line status. bit 5 = lck: locked . set by hardware when at least two consecutive sof packets have been received after the end of a usb reset condition or after the end of a usb resume sequence. 0: frame timer not locked 1: frame timer locked note: once locked, the frame timer remains in this state until a usb reset or usb suspend event oc- curs. bits 4:3 = lsof[1:0] : lost sof . set by hardware when an esof interrupt is gener- ated, counting the number of consecutive sof packets lost. on reception of a sof packet, these bits are cleared. bits 2:0 = fn[10:8]: frame number bits 10:8 . these bits contain the most significant bits of the frame number received with the last received sof packet. these bits are updated when a sof interrupt is generated. frame number register low (fnrl) r255 - read-only register page: 15 reset value: xxxx xxxx (xxh) bits 7:0 = fn[7:0]: frame number bits 7:0 . set by hardware, this register contains the least significant bits of the 11-bit frame number con- tained in the last received sof packet. the 3 re- maining most significant bits are stored in the fnrh register. this register is updated when a sof interrupt is generated. 8.3.4.2 device and endpoint specific registers for each function a daddr register is available to store the device address and for each endpoint a pair of epnr registers is available to store end- point specific information. 70 0 0 into enid3 enid2 enid1 enid0 0 70 rxdp rxdm lck lsof1 lsof0 fn10 fn9 fn8 70 fn7 fn6 fn5 fn4 fn3 fn2 fn1 fn0
143/224 st92163 - usb peripheral (usb) usb interface ( cont'd ) device n address (daddrn) r240 to r247 - read/write register page: 15 reset value: 0000 0000 (00h) note: this register is also reset when a usb reset is received from the usb bus or forced through bit fres in the usbctlr register. bit 7 = ef : enable function . set by software to enable the usb function whose address is contained in the following add[6:0] bits. 0: function disabled 1: function enabled bits 6:0 = add[6:0] : device address . software must write into these bits the usb device address assigned by the host pc during the enu- meration. endpoint n register a (epnra) (transmission) r240-r254 (even) read/write register pages: 4 & 5 reset value: 0000 0000 (00h) these registers are used for controlling data trans- mission. they are also reset when a usb reset is received or forced through the fres bit in the us- bctlr register. note: the ctr bits are not affected by a usb re- set each endpoint has its epnra register where n is the endpoint identifier in the range 0 to 15. bit 7 = ctr : correct transfer . set by hardware when a transaction is successful- ly completed on this endpoint; software can only clear this bit. 0: no correct transfer occured 1: correct transfer occured note: a transaction ended with a nak or stall handshake does not set this bit, since no data is actually transferred, as in the case of protocol er- rors or data toggle mismatches. the ctr bit is also used to perform flow control: while ctr=1, a valid endpoint answers nak to every transaction addressed to it (except setup requests which are simply ignored) until the application software ac- knowledges the ctr event, resetting this bit. this does not apply to isochronous endpoints where no handshake phase is used. bit 6 = dtog_tx : data toggle, for transmission transfers . if the endpoint is non-isochronous, this bit contains the required value of the data toggle bit (0=data0, 1=data1) for the next data packet to be transmitted. hardware toggles this bit when the ack handshake is received from the usb host, following a data packet transmission. if the end- point is defined as a control one, hardware sets this bit to 1 on reception of a setup pid ad- dressed to this endpoint. if the endpoint is isochronous, this bit is used to support dma buffer swapping since no data tog- gling is used for this sort of endpoint and only data0 packet are transmitted. hardware toggles this bit just after the end of data packet transmis- sion, since no handshake is used for isochronous transfers. note: this bit can be also written by software to in- itialize it (mandatory when the endpoint is not a control endpoint) or to force specific data toggle/ dma buffer usage. 70 ef add6 add5 add4 add3 add2 add1 add0 70 ctr dtog_ tx stat_ tx1 stat_ tx0 pidr1 pidr0 cep iso
144/224 st92163 - usb peripheral (usb) usb interface ( cont'd ) bit 5:4 = stat_tx [1:0] status bits, for transmis- sion transfers . these bits contain the information about the end- point status, which are listed below: table 25. transmission status encoding these bits are written by software, but hardware sets the stat_tx bits to nak when a correct transfer has occurred (ctr=1) related to a in or setup (control only) transaction addressed to this endpoint, waiting for the software to prepare the next set of data to be transmitted. if the end- point is defined as isochronous, its status can be only avalido or adisabledo so no hardware change of the endpoint status will take place after a successful transaction. bits 3:2 = pidr[1:0] : pid received . these bits are read-only and contain the two most significant bits of the pid field of the last token pid addressed to this endpoint. these bits are kept frozen while ctr bit is at 1. the usb standard defines pidr bits as in the fol- lowing table: table 26. pid encoding bit 1 = cep : control endpoint . software must set this bit to configure this end- point as a control endpoint. 0: non-control endpoint 1: control endpoint notes: if a control endpoint is defined as nak in the receive direction, the usb interface will not an- swer, when a setup transaction is received. if the control endpoint is defined as stall in the receive direction, then the setup packet will be accepted anyway, transferring data and issuing the ctr interrupt. bit 0 = iso : isochronous endpoint . software must set this bit to configure this end- point as an isochronous endpoint. 0: not an isochronous endpoint 1:isochronous endpoint note: since isochronous transfer has no hand- shake phase, the only legal values for the stat_rx/stat_tx bit pairs are `00' (disabled) and `11' (valid), any other value will produce re- sults not compliant to the usb standard. iso- chronous endpoints implement double-buffering, using both `transmission' and `reception' memory areas to manage buffer swapping on each suc- cessful transaction. the memory buffer that is currently used by the usb interface is defined by the dtog bit corre- sponding to the endpoint direction (dtog_rx in epnrb for `reception' isochronous endpoints, dtog_tx in epnra for `transmission' iso- chronous endpoints) according to the following ta- ble: table 27. isochronous memory buffers usage since the swapped buffer management requires the usage of all 8 register file locations hosting the address pointer and the length of the allocated memory buffers, isochronous endpoints are forced to be unidirectional so it is not possible to enable an isochronous endpoint both for transmission and reception. stat_tx [1:0] meaning 00 disabled: all transmission requests ad- dressed to this endpoint are ignored. 01 stall : the endpoint is stalled and all trans- mission requests result in a stall hand- shake. 10 nak : the endpoint is naked and all trans- mission requests result in a nak hand- shake. 11 valid : this endpoint is enabled for trans- mission. pidr[1:0] pid 00 out 10 in 11 setup dtog bit value dma buffer used by usb interface dma buffer used by application software 0 addrn_t / countn_t register file locations. addrn_r / countn_r register file locations. 1 addrn_r / countn_r register file locations. addrn_t / countn_t register file locations.
145/224 st92163 - usb peripheral (usb) usb interface ( cont'd ) endpoint n register b (epnrb) (reception) r241-r255 (odd) - read/write register pages: 4 & 5 reset value: 0000 0000 (00h) these registers are used for controlling data re- ception. they are also reset when a usb reset is received from the usb bus or forced through bit fres in the usbctlr register. each endpoint has its epnrb register where n is the endpoint identifier in the range 0 to 15. bit 7 = st_out status out . this bit is set by software to indicate that a status out transaction is expected: in this case all out transactions containing more than zero data bytes are answered stall instead of ack. this bit may be used to improve the robustness of the applica- tion to protocol errors during control transfers and its usage is intended on control endpoints only. when st_out is reset, out transactions can have any number of bytes, as needed. bit 6 = dtog_rx : data toggle, for reception transfers . if the endpoint is non-isochronous, this bit contains the expected value of the data toggle bit (0=data0, 1=data1) for the next data packet to be received. hardware toggles this bit when the ack handshake is sent to the usb host, following a data packet reception with a matching data pid value. if the endpoint is defined as a control end- point, hardware resets this bit on reception of a setup pid addressed to this endpoint. if the endpoint is isochronous, this bit is used to support dma buffer swapping since no data tog- gling is used for this sort of endpoint and only data0 packets are received. hardware toggles this bit just after the end of data packet reception, since no handshake is used for isochronous trans- fers. note: this bit can be also written by software to in- itialize it (mandatory when the endpoint is not a control endpoint) or to force a specific data toggle/ dma buffer usage. bit 5:4 = stat_rx [1:0] status bits, for reception transfers . these bits contain the information about the end- point status, as listed below: table 28. reception status encoding these bits are written by software, but hardware sets the stat_rx bits to nak when a correct transfer has occurred (ctr=1) related to a out or setup (control only) transaction addressed to this endpoint, so software has time to interpret the received data before acknowledging a new trans- action. if the endpoint is defined as isochronous, its status can be only avalido or adisabledo so no hard- ware change of the endpoint status will take place after a successful transaction. bit 3:0 = ena[3:0] endpoint n address, bits 3-0. software must write in this field the 4-bit address used to identify the transactions directed to this endpoint. a value must be written before enabling the corresponding endpoint. 70 st_ou t dtog_ rx stat_ rx1 stat_ rx0 ena3 ena2 ena1 ena0 stat_tx [1:0] meaning 00 disabled: all reception requests ad- dressed to this endpoint are ignored. 01 stall : the endpoint is stalled and all re- ception requests result in a stall hand- shake. 10 nak : the endpoint is naked and all recep- tion requests result in a nak handshake. 11 valid : this endpoint is enabled for recep- tion.
146/224 st92163 - usb peripheral (usb) usb interface ( cont'd ) 8.3.4.3 miscellaneous registers these registers contain device configuration pa- rameters or optional functions of usb interface. device configuration 1 (devconf1) r244 - read/write register page: 60 reset value: 0000 1111 (0fh) this register contains device configuration data that should be written by the software at the begin- ning of the application program and should never be changed during normal operations. bit 7:6 = reserved. this bit is fixed by hardware at 0. bit 6 = reserved. must be kept at 0. bit 5 = usboe_en : usboe signal enable . set by software to enable the alternate output function connected to the upstream output enable signal. 1: usboe signal output enabled 0: usboe signal output disabled bit 4 = reserved. bits 3:0 = reserved. these bits are fixed by hard- ware at 1. device configuration 2 (devconf2) r245 - read/write register page: 60 reset value: 0000 0000 (00h) this register contains device configuration data that should be written by the software at the begin- ning of the application program and should never be changed during normal operations. bits 7:2 = reserved. these bits must be always written to 0. bit 1 = lvd_disable : low voltage detector dis- able set by the software to disable the generation of the device reset signal by the lvd. 1: lvd disabled 0: lvd enabled if this bit is at 0, an internal reset can be issued both by the external reset pin and the lvd when it detects a low supply voltage; if this bit is at 1 only the external pad can start a device reset. note: this bit can be only set to 1 by software, writ- ing 0 has no effect and the lvd can be re-enabled only using a device reset. 70 0- usboe _en ls_ device 1111 70 000000 lvd_ disab le sofp_ enable
147/224 st92163 - usb peripheral (usb) usb interface ( cont'd ) bit 0 = sofp_enable : start-of-frame pulse enable. set by software to enable the use of the usbsof alternate output function. 1: usbsof alternate function enabled 0: usbsof output disabled usbsof outputs a 333.33 ns long pulse at each frame start (actually 10 bits before the sof packet expected start). this pulse is not generated until two sof packets are received after any usb reset or usb resume (frame timer locking) and they stop as soon as the suspend condition is entered (tim_susp bit in usbctlr register). mirror register a (mirra) r246 - read/write register page: 60 reset value: xxxx xxxx (xxh) bit 7:0 = mira[7:0] mirror register a, bits 7-0. this register acts as a bit mirroring location where software can write a byte and read it back with the lsb and msb position swapped. mirror register b (mirrb) r247 - read/write register page: 60 reset value: xxxx xxxx (xxh) bit 7:0 = mirb[7:0] mirror register b, bits 7-0. this register acts as a bit mirroring location where software can write a byte and read it back with the lsb and msb position swapped. 70 mira7 mira6 mira5 mira4 mira3 mira2 mira1 mira0 70 mirb7 mirb6 mirb5 mirb4 mirb3 mirb2 mirb1 mirb0
148/224 st92163 - usb peripheral (usb) usb interface ( cont'd ) 8.3.5 register pages summary the registers are located in different register file pages. to help finding the correct page for each register, the following tables show the page map- ping of all usb registers. table 29. usb register page mapping table 30. usb register page 15 map and reset values address page 4 page 5 page 15 page 60 240 (f0h) ep0ra ep8ra daddr0 241 (f1h) ep0rb ep8rb daddr1 242 (f2h) ep1ra ep9ra daddr2 243 (f3h) ep1rb ep9rb daddr3 244 (f4h) ep2ra ep10ra daddr4 devconf1 245 (f5h) ep2rb ep10rb daddr5 devconf2 246 (f6h) ep3ra ep11ra daddr6 mirra 247 (f7h) ep3rb ep11rb daddr7 mirrb 248 (f8h) ep4ra ep12ra usbivr 249 (f9h) ep4rb ep12rb usbistr 250 (fah) ep5ra ep13ra usbimr 251 (fbh) ep5rb ep13rb usbipr 252 (fch) ep6ra ep14ra usbctlr 253 (fdh) ep6rb ep14rb ctrinf 254 (feh) ep7ra ep15ra fnrh 255 (ffh) ep7rb ep15rb fnrl reg. no. register name 76543210 r240 - r247 daddrn reset value ef 0 add6 0 add5 0 add4 0 add3 0 add2 0 add1 0 add0 0 r248 usbivr reset value a1 x a0 x ctro x v3 x v2 x v1 x v0 x 0 0 r249 usbistr reset value 0 0 dovr 0 dovr 0 esusp 0 susp 0 reset 0 sof 0 esof 0 r250 usbimr reset value 0 0 dovrm 0 dovrm 0 esuspm 0 suspm 0 resetm 0 sofm 0 esofm 0 r251 usbipr reset value iee 0 piece2 x piece1 x piece0 x niee 0 pnien2 x pnien1 x pnien0 x r252 usbctlr reset value 0 0 tim_susp 0 0 0 sdnav 1 resume 0 pdwn 1 lp_susp 0 fres 1
149/224 st92163 - usb peripheral (usb) r253 ctrinf reset value 0 0 0 0 into x enid3 x enid2 x enid1 x enid0 x 0 0 r254 fnrh reset value rxdp 0 rxdm 0 lck 0 lsof1 0 lsof0 0 fn10 x fn9 x fn8 x r255 fnrl reset value fn7 x fn6 x fn5 x fn4 x fn3 x fn2 x fn1 x fn0 x reg. no. register name 76543210
150/224 st92163 - serial communications interface (sci) 8.4 serial communications interface (sci) 8.4.1 introduction the serial communications interface (sci) offers full-duplex serial data exchange with a wide range of external equipment. the sci offers four operat- ing modes: asynchronous, asynchronous with synchronous clock, serial expansion and syn- chronous. the sci offers the following principal features: n full duplex synchronous and asynchronous operation. n transmit, receive, line status, and device address interrupt generation. n integral baud rate generator capable of dividing the input clock by any value from 2 to 2 16 -1 (16 bit word) and generating the internal 16x data sampling clock for asynchronous operation or the 1x clock for synchronous operation. n fully programmable serial interface: 5, 6, 7, or 8 bit word length. even, odd, or no parity generation and detec- tion. 0, 1, 1.5, 2, 2.5, 3 stop bit generation. complete status reporting capabilities. line break generation and detection. n programmable address indication bit (wake-up bit) and user invisible compare logic to support multiple microcomputer networking. optional character search function. n internal diagnostic capabilities: local loopback for communications link fault isolation. auto-echo for communications link fault isola- tion. n separate interrupt/dma channels for transmit and receive. n in addition, a synchronous mode supports: high speed communication possibility of hardware synchronization (rts/ dcd signals). programmable polarity and stand-by level for data sin/sout. programmable active edge and stand-by level for clocks clkout/rxcl. programmable active levels of rts/dcd sig- nals. full loop-back and auto-echo modes for da- ta, clocks and controls. figure 71. sci block diagram transmit buffer register register shift transmit register shift receiver function alternate register compare address register buffer receiver dma controller clock and baud rate generator st9 core bus sout txclk/clkout rxclk sin va00169a frame control and status dma controller rts dcd sds
151/224 st92163 - serial communications interface (sci) serial communications interface (cont'd) 8.4.2 functional description the sci offers four operating modes: asynchronous mode asynchronous mode with synchronous clock serial expansion mode synchronous mode asynchronous mode, asynchronous mode with synchronous clock and serial expansion mode output data with the same serial frame format. the differences lie in the data sampling clock rates (1x, 16x) and in the protocol used. figure 72. sci functional schematic note: some pins may not be available on some devices. refer to the device pinout description. divider by 16 1 0 1 0 divider by 16 cd cd the control signals marked with (*) are active only in synchronous mode (smen=1) polarity polarity txclk / clkout rx shift register tx buffer register tx shift register rtsen (*) enveloper aen (*) outsb (*) stand by polarity sout aen rx buffer register polarity polarity stand by polarity baud rate generator rxclk ocksb (*) lben (*) intclk xbrg aen (*) oclk xtclk dcden (*) dcd rts sin inpl (*) lben outpl (*) inpen (*) ockpl (*) xrx oclk vr02054
152/224 st92163 - serial communications interface (sci) serial communications interface (cont'd) 8.4.3 sci operating modes 8.4.3.1 asynchronous mode in this mode, data and clock can be asynchronous (the transmitter and receiver can use their own clocks to sample received data), each data bit is sampled 16 times per clock period. the baud rate clock should be set to the 16 mode and the frequency of the input clock (from an ex- ternal source or from the internal baud-rate gener- ator output) is set to suit. 8.4.3.2 asynchronous mode with synchronous clock in this mode, data and clock are synchronous, each data bit is sampled once per clock period. for transmit operation, a general purpose i/o port pin can be programmed to output the clkout signal from the baud rate generator. if the sci is provided with an external transmission clock source, there will be a skew equivalent to two intclk periods between clock and data. data will be transmitted on the falling edge of the transmit clock. received data will be latched into the sci on the rising edge of the receive clock. figure 73. sampling times in asynchronous format 012345 789101112131415 sdin rcvck rxd rxclk vr001409 legend: sin: rcvck: rxd: rxclk: serial data input line internal x16 receiver clock internal serial data input line internal receiver shift register sampling clock
153/224 st92163 - serial communications interface (sci) serial communications interface (cont'd) 8.4.3.3 serial expansion mode this mode is used to communicate with an exter- nal synchronous peripheral. the transmitter only provides the clock waveform during the period that data is being transmitted on the clkout pin (the data envelope). data is latched on the rising edge of this clock. whenever the sci is to receive data in serial port expansion mode, the clock must be supplied ex- ternally, and be synchronous with the transmitted data. the sci latches the incoming data on the ris- ing edge of the received clock, which is input on the rxclk pin. 8.4.3.4 synchronous mode this mode is used to access an external synchro- nous peripheral, dummy start/stop bits are not in- cluded in the data frame. polarity, stand-by level and active edges of i/o signals are fully and sepa- rately programmable for both inputs and outputs. it's necessary to set the smen bit of the synchro- nous input control register (sicr) to enable this mode and all the related extra features (otherwise disabled). the transmitter will provide the clock waveform only during the period when the data is being transmitted via the clkout pin, which can be en- abled by setting both the xtclk and oclk bits of the clock configuration register. whenever the sci is to receive data in synchronous mode, the clock waveform must be supplied externally via the rxclk pin and be synchronous with the data. for correct receiver operation, the xrx bit of the clock configuration register must be set. two external signals, request-to-send and data- carrier-detect (rts/dcd), can be enabled to syn- chronise the data exchange between two serial units. the rts output becomes active just before the first active edge of clkout and indicates to the target device that the mcu is about to send a synchronous frame; it returns to its stand-by state following the last active edge of clkout (msb transmitted). the dcd input can be considered as a gate that filters rxclk and informs the mcu that a trans- mitting device is transmitting a data frame. polarity of rts/dcd is individually programmable, as for clocks and data. the data word is programmable from 5 to 8 bits, as for the other modes; parity, address/9th, stop bits and break cannot be inserted into the transmitted frame. programming of the related bits of the sci control registers is irrelevant in synchronous mode: all the corresponding interrupt requests must, in any case, be masked in order to avoid in- correct operation during data reception.
154/224 st92163 - serial communications interface (sci) serial communications interface (cont'd) figure 74. sci operating modes note: in all operating modes, the least significant bit is transmitted/received first. asynchronous mode asynchronous mode with synchronous clock serial expansion mode synchronous mode i/o clock start bit data parity stop bit 16 16 16 va00271 i/o clock start bit data parity stop bit va00272 i/o clock data va0273a start bit (dummy) stop bit (dummy) stand-by clock data vr02051 stand-by stand-by stand-by rts/dcd stand-by stand-by
155/224 st92163 - serial communications interface (sci) serial communications interface (cont'd) 8.4.4 serial frame format characters sent or received by the sci can have some or all of the features in the following format, depending on the operating mode: start : the start bit indicates the beginning of a data frame in asynchronous modes. the start condition is detected as a high to low transition. a dummy start bit is generated in serial expan- sion mode. the start bit is not generated in synchronous mode. data : the data word length is programmable from 5 to 8 bits, for both synchronous and asyn- chronous modes. lsb are transmitted first. parity : the parity bit (not available in serial ex- pansion mode and synchronous mode) is option- al, and can be used with any word length. it is used for error checking and is set so as to make the total number of high bits in data plus parity odd or even, depending on the number of a1os in the data field. address/9th : the address/9th bit is optional and may be added to any word format. it is used in both serial expansion and asynchronous modes to indicate that the data is an address (bit set). the address/9th bit is useful when several mi- crocontrollers are exchanging data on the same serial bus. individual microcontrollers can stay idle on the serial bus, waiting for a transmitted ad- dress. when a microcontroller recognizes its own address, it can begin data reception, likewise, on the transmit side, the microcontroller can transmit another address to begin communication with a different microcontroller. the address/9th bit can be used as an addi- tional data bit or to mark control words (9th bit). stop : indicates the end of a data frame in asyn- chronous modes. a dummy stop bit is generated in serial expansion mode. the stop bit can be programmed to be 1, 1.5, 2, 2.5 or 3 bits long, de- pending on the mode. it returns the sci to the qui- escent marking state (i.e., a constant high-state condition) which lasts until a new start bit indicates an incoming word. the stop bit is not generated in synchronous mode. figure 75. sci character formats (1) lsb first (2) not available in synchronous mode (3) not available in serial expansion mode and synchronous mode start (2) data (1) parity (3) address (2) stop (2) # bits 1 5,6,7,8 0,1 0,1 1, 1.5, 2, 2.5, 1, 2, 3 16x 1x states none odd even on off
156/224 st92163 - serial communications interface (sci) serial communications interface (cont'd) 8.4.4.1 data transfer data to be transmitted by the sci is first loaded by the program into the transmitter buffer register. the sci will transfer the data into the transmitter shift register when the shift register becomes available (empty). the transmitter shift register converts the parallel data into serial format for transmission via the sci alternate function out- put, serial data out. on completion of the transfer, the transmitter buffer register interrupt pending bit will be updated. if the selected word length is less than 8 bits, the unused most significant bits do not need to be defined. incoming serial data from the serial data input pin is converted into parallel format by the receiver shift register. at the end of the input data frame, the valid data portion of the received word is trans- ferred from the receiver shift register into the re- ceiver buffer register. all receiver interrupt con- ditions are updated at the time of transfer. if the selected character format is less than 8 bits, the unused most significant bits will be set. the frame control and status block creates and checks the character configuration (data length and number of stop bits), as well as the source of the transmitter/receiver clock. the internal baud rate generator contains a pro- grammable divide by ano counter which can be used to generate the clocks for the transmitter and/or receiver. the baud rate generator can use intclk or the receiver clock input via rxclk. the address bit/d9 is optional and may be added to any word in asynchronous and serial expan- sion modes. it is commonly used in network or ma- chine control applications. when enabled (ab set), an address or ninth data bit can be added to a transmitted word by setting the set address bit (sa). this is then appended to the next word en- tered into the (empty) transmitter buffer register and then cleared by hardware. on character input, a set address bit can indicate that the data pre- ceding the bit is an address which may be com- pared in hardware with the value in the address compare register (acr) to generate an address match interrupt when equal. the address bit and address comparison regis- ter can also be combined to generate four different types of address interrupt to suit different proto- cols, based on the status of the address mode en- able bit (amen) and the address mode bit (am) in the chcr register. the character match address interrupt mode may be used as a powerful character search mode, generating an interrupt on reception of a predeter- mined character e.g. carriage return or end of block codes (character match interrupt). this is the only address interrupt mode available in syn- chronous mode. the line break condition is fully supported for both transmission and reception. line break is sent by setting the sb bit (idpr). this causes the trans- mitter output to be held low (after all buffered data has been transmitted) for a minimum of one com- plete word length and until the sb bit is reset. break cannot be inserted into the transmitted frame for the synchronous mode. testing of the communications channel may be performed using the built-in facilities of the sci pe- ripheral. auto-echo mode and loop-back mode may be used individually or together. in asynchro- nous, asynchronous with synchronous clock and serial expansion modes they are available only on sin/sout pins through the programming of aen/ lben bits in ccr. in synchronous mode (smen set) the above configurations are available on sin/ sout, rxclk/clkout and dcd/rts pins by programming the aen/lben bits and independ- ently of the programmed polarity. in the synchro- nous mode case, when aen is set, the transmitter outputs (data, clock and control) are disconnected from the i/o pins, which are driven directly by the receiver input pins (auto-echo mode: sout=sin, clkout=rxclk and rts=dcd, even if they act on the internal receiver with the programmed po- larity/edge). when lben is set, the receiver inputs (data, clock and controls) are disconnected and the transmitter outputs are looped-back into the re- ceiver section (loop-back mode: sin=sout, rx- clk=clkout, dcd=rts. the output pins are locked to their programmed stand-by level and the status of the inpl, xckpl, dcdpl, outpl, ockpl and rtspl bits in the sicr register are ir- relevant). refer to figure 6, figure 7, and figure 8 for these different configurations. table 31. address interrupt modes (1) not available in synchronous mode if 9th data bit is set (1) if character match if character match and 9th data bit is set (1) if character match immediately follows break (1)
157/224 st92163 - serial communications interface (sci) serial communications interface (cont'd) figure 76. auto echo configuration figure 77. loop back configuration figure 78. auto echo and loop-back configuration all modes except synchronous synchronous mode (smen=1) receiver sin sout vr000210 transmitte r receiver sin sout vr00210a trans mitter dcd rts rxclk clkout all modes except synchronous synchronous mode (smen=1) receiver sin sout vr000211 transmitt er logical 1 receiver sin sout vr00211a transmit ter dcd rts rxclk clkout stand-by value stand-by value stand-by value clock data all modes except synchronous synchronous mode (smen=1) receive r sin sout vr000212 transmi tter receiver sin sout vr00212a transmit ter dcd rts rxclk clkout clock data
158/224 st92163 - serial communications interface (sci) serial communications interface (cont'd) 8.4.5 clocks and serial transmission rates the communication bit rate of the sci transmitter and receiver sections can be provided from the in- ternal baud rate generator or from external sources. the bit rate clock is divided by 16 in asynchronous mode (cd in ccr reset), or undi- vided in the 3 other modes (cd set). with intclk running at 24mhz and no external clock provided, a maximum bit rate of 3mbaud and 750kbaud is available in undivided and divide by-16-mode respectively. with intclk running at 24mhz and an external clock provided through the rxclk/txclk lines, a maximum bit rate of 3mbaud and 375kbaud is avaiable in undivided and divided by 16 mode re- spectively (see figure 10 oreceiver and transmit- ter clock frequencieso)o external clock sources. the external clock in- put pin txclk may be programmed by the xtclk and oclk bits in the ccr register as: the transmit clock input, baud rate generator output (allowing an external divider circuit to provide the receive clock for split rate transmit and receive), or as clkout output in synchronous and serial ex- pansion modes. the rxclk receive clock input is enabled by the xrx bit, this input should be set in accordance with the setting of the cd bit. baud rate generator. the internal baud rate generator consists of a 16-bit programmable di- vide by ano counter which can be used to generate the transmitter and/or receiver clocks. the mini- mum baud rate divisor is 2 and the maximum divi- sor is 2 16 -1. after initialising the baud rate genera- tor, the divisor value is immediately loaded into the counter. this prevents potentially long random counts on the initial load. the baud rate generator frequency is equal to the input clock frequency divided by the divisor value. warning: programming the baud rate divider to 0 or 1 will stop the divider. the output of the baud rate generator has a pre- cise 50% duty cycle. the baud rate generator can use intclk for the input clock source. in this case, intclk (and therefore the mcu xtal) should be chosen to provide a suitable frequency for division by the baud rate generator to give the required transmit and receive bit rates. suitable intclk frequencies and the respective divider values for standard baud rates are shown in table 2. 8.4.6 sci initialization procedure writing to either of the two baud rate generator registers immediately disables and resets the sci baud rate generator, as well as the transmitter and receiver circuitry. after writing to the second baud rate generator register, the transmitter and receiver circuits are enabled. the baud rate generator will load the new value and start counting. to initialize the sci, the user should first initialize the most significant byte of the baud rate gener- ator register; this will reset all sci circuitry. the user should then initialize all other sci registers (sicr/socr included) for the desired operating mode and then, to enable the sci, he should ini- tialize the least significant byte baud rate gener- ator register. 'on-the-fly' modifications of the control registers' content during transmitter/receiver operations, al- though possible, can corrupt data and produce un- desirable spikes on the i/o lines (data, clock and control). furthermore, modifying the control regis- ters' content without reinitialising the sci circuitry (during stand-by cycles, waiting to transmit or re- ceive data) must be kept carefully under control by software to avoid spurious data being transmitted or received. note : for synchronous receive operation, the data and receive clock must not exhibit significant skew between clock and data. the received data and clock are internally synchronized to intclk. figure 79. sci baud rate generator initialization sequence select sci working mode least significant byte initializatio n most significant byte initializatio n
159/224 st92163 - serial communications interface (sci) serial communications interface (cont'd) table 32. sci baud rate generator divider values example 1 table 33. sci baud rate generator divider values example 2 intclk: 19660.800 khz baud rate clock factor desired freq (khz) divisor actual baud rate actual freq (khz) deviation dec hex 50.00 16 x 0.80000 24576 6000 50.00 0.80000 0.0000% 75.00 16 x 1.20000 16384 4000 75.00 1.20000 0.0000% 110.00 16 x 1.76000 11170 2ba2 110.01 1.76014 -0.00081% 300.00 16 x 4.80000 4096 1000 300.00 4.80000 0.0000% 600.00 16 x 9.60000 2048 800 600.00 9.60000 0.0000% 1200.00 16 x 19.20000 1024 400 1200.00 19.20000 0.0000% 2400.00 16 x 38.40000 512 200 2400.00 38.40000 0.0000% 4800.00 16 x 76.80000 256 100 4800.00 76.80000 0.0000% 9600.00 16 x 153.60000 128 80 9600.00 153.60000 0.0000% 19200.00 16 x 307.20000 64 40 19200.00 307.20000 0.0000% 38400.00 16 x 614.40000 32 20 38400.00 614.40000 0.0000% 76800.00 16 x 1228.80000 16 10 76800.00 1228.80000 0.0000% intclk: 24576 khz baud rate clock factor desired freq (khz) divisor actual baud rate actual freq (khz) deviation dec hex 50.00 16 x 0.80000 30720 7800 50.00 0.80000 0.0000% 75.00 16 x 1.20000 20480 5000 75.00 1.20000 0.0000% 110.00 16 x 1.76000 13963 383b 110.01 1.76014 -0.00046% 300.00 16 x 4.80000 5120 1400 300.00 4.80000 0.0000% 600.00 16 x 9.60000 2560 a00 600.00 9.60000 0.0000% 1200.00 16 x 19.20000 1280 500 1200.00 19.20000 0.0000% 2400.00 16 x 38.40000 640 280 2400.00 38.40000 0.0000% 4800.00 16 x 76.80000 320 140 4800.00 76.80000 0.0000% 9600.00 16 x 153.60000 160 a0 9600.00 153.60000 0.0000% 19200.00 16 x 307.20000 80 50 19200.00 307.20000 0.0000% 38400.00 16 x 614.40000 40 28 38400.00 614.40000 0.0000% 76800.00 16 x 1228.80000 20 14 76800.00 1228.80000 0.0000%
160/224 st92163 - serial communications interface (sci) serial communications interface (cont'd) 8.4.7 input signals sin: serial data input . this pin is the serial data input to the sci receiver shift register. txclk: external transmitter clock input . this pin is the external input clock driving the sci trans- mitter. the txclk frequency must be greater than or equal to 16 times the transmitter data rate (de- pending whether the x16 or the x1 clock have been selected). a 50% duty cycle is required for this input and must have a period of at least twice intclk. the use of the txclk pin is optional. rxclk: external receiver clock input. this in- put is the clock to the sci receiver when using an external clock source connected to the baud rate generator. intclk is normally the clock source. a 50% duty cycle is required for this input and must have a period of at least twice intclk. use of rx- clk is optional. dcd: data carrier detect. this input is enabled only in synchronous mode; it works as a gate for the rxclk clock and informs the mcu that an emitting device is transmitting a synchronous frame. the active level can be programmed as 1 or 0 and must be provided at least one intclk pe- riod before the first active edge of the input clock. 8.4.8 output signals sout: serial data output. this alternate func- tion output signal is the serial data output for the sci transmitter in all operating modes. clkout: clock output . the alternate function of this pin outputs either the data clock from the transmitter in serial expansion or synchronous modes, or the clock output from the baud rate generator. in serial expansion mode it will clock only the data portion of the frame and its stand-by state is high: data is valid on the rising edge of the clock. even in synchronous mode clkout will only clock the data portion of the frame, but the stand-by level and active edge polarity are pro- grammable by the user. when synchronous mode is disabled (smen in sicr is reset), the state of the xtclk and oclk bits in ccr determine the source of clkout; '11' enables the serial expansion mode. when the synchronous mode is enabled (smen in sicr is set), the state of the xtclk and oclk bits in ccr determine the source of clkout; '00' disables it for plm applications. rts: request to send. this output alternate function is only enabled in synchronous mode; it becomes active when the least significant bit of the data frame is sent to the serial output pin (sout) and indicates to the target device that the mcu is about to send a synchronous frame; it re- turns to its stand-by value just after the last active edge of clkout (msb transmitted). the active level can be programmed high or low. sds: synchronous data strobe. this output al- ternate function is only enabled in synchronous mode; it becomes active high when the least sig- nificant bit is sent to the serial output pins (sout) and indicates to the target device that the mcu is about to send the first bit for each synchro- nous frame. it is active high on the first bit and it is low for all the rest of the frame. the active level can not be programmed. figure 80. receiver and transmitter clock frequencies note: the internal receiver and transmitter clocks are the ones applied to the tx and rx shift regis- ters (see figure 1). min max conditions receiver clock frequency external rxclk 0 intclk/8 1x mode 0 intclk/4 16x mode internal receiver clock 0 intclk/8 1x mode 0 intclk/2 16x mode transmitter clock frequency external txclk 0 intclk/8 1x mode 0 intclk/4 16x mode internal transmitter clock 0 intclk/8 1x mode 0 intclk/2 16x mode
161/224 st92163 - serial communications interface (sci) serial communications interface (cont'd) 8.4.9 interrupts and dma 8.4.9.1 interrupts the sci can generate interrupts as a result of sev- eral conditions. receiver interrupts include data pending, receive errors (overrun, framing and par- ity), as well as address or break pending. trans- mitter interrupts are software selectable for either transmit buffer register empty (bsn set) or for transmit shift register empty (bsn reset) condi- tions. typical usage of the interrupts generated by the sci peripheral are illustrated in figure 11. the sci peripheral is able to generate interrupt re- quests as a result of a number of events, several of which share the same interrupt vector. it is therefore necessary to poll s_isr, the interrupt status register, in order to determine the active trigger. these bits should be reset by the program- mer during the interrupt service routine. the four major levels of interrupt are encoded in hardware to provide two bits of the interrupt vector register, allowing the position of the block of point- er vectors to be resolved to an 8 byte block size. the sci interrupts have an internal priority struc- ture in order to resolve simultaneous events. refer also to section 0.1.3 for more details relating to synchronous mode. table 34. sci interrupt internal priority receive dma request highest priority transmit dma request receive interrupt transmit interrupt lowest priority
162/224 st92163 - serial communications interface (sci) serial communications interface (cont'd) table 35. sci interrupt vectors figure 81. sci interrupts: example of typical usage interrupt source vector address transmitter buffer or shift register empty transmit dma end of block xxx x110 received data pending receive dma end of block xxxx x100 break detector address word match xxxx x010 receiver error xxxx x000 interrupt break match address data address after break condition address word marked by d9=1 address interrupt interrupt d9=1 d9 acting as data control with separate interrupt character search mode interrupt va00270 break break interrupt data interrupt data interrupt data interrupt data interrupt data interrupt data interrupt data interrupt data interrupt data interrupt data interrupt data interrupt data interrupt data interrupt data interrupt data interrupt interrupt interrupt data address data data data data no match address break data no match address match data data data match data char match data data data data address data data d9=1 data data data data
163/224 st92163 - serial communications interface (sci) serial communications interface (cont'd) 8.4.9.2 dma two dma channels are associated with the sci, for transmit and for receive. these follow the reg- ister scheme as described in the dma chapter. dma reception to perform a dma transfer in reception mode: 1. initialize the dma counter (rdcpr) and dma address (rdapr) registers 2. enable dma by setting the rxd bit in the idpr register. 3. dma transfer is started when data is received by the sci. dma transmission to perform a dma transfer in transmission mode: 1. initialize the dma counter (tdcpr) and dma address (tdapr) registers. 2. enable dma by setting the txd bit in the idpr register. 3. dma transfer is started by writing a byte in the transmitter buffer register (txbr). if this byte is the first data byte to be transmitted, the dma counter and address registers must be initialized to begin dma transmission at the sec- ond byte. alternatively, dma transfer can be start- ed by writing a dummy byte in the txbr register. dma interrupts when dma is active, the received data pending and the transmitter shift register empty interrupt sources are replaced by the dma end of block re- ceive and transmit interrupt sources. note: to handle dma transfer correctly in trans- mission, the bsn bit in the imr register must be cleared. this selects the transmitter shift register empty event as the dma interrupt source. the transfer of the last byte of a dma data block will be followed by a dma end of block transmit or receive interrupt, setting the txeob or rxeob bit. a typical transmission end of block interrupt rou- tine will perform the following actions: 1. restore the dma counter register (tdcpr). 2. restore the dma address register (tdapr). 3. clear the transmitter shift register empty bit txsem in the s_isr register to avoid spurious interrupts. 4. clear the transmitter end of block (txeob) pending bit in the imr register. 5. set the txd bit in the idpr register to enable dma. 6. load the transmitter buffer register (txbr) with the next byte to transmit. the above procedure handles the case where a further dma transfer is to be performed. error interrupt handling if an error interrupt occurs while dma is enabled in reception mode, dma transfer is stopped. to resume dma transfer, the error interrupt han- dling routine must clear the corresponding error flag. in the case of an overrun error, the routine must also read the rxbr register. character search mode with dma in character search mode with dma, when a character match occurs, this character is not trans- ferred. dma continues with the next received char- acter. to avoid an overrun error occurring, the character match interrupt service routine must read the rxbr register.
164/224 st92163 - serial communications interface (sci) serial communications interface (cont'd) 8.4.10 register description the sci registers are located in the following pag- es in the st9: sci number 0: page 24 (18h) sci number 1: page 25 (19h) (when present) the sci is controlled by the following registers: address register r240 (f0h) receiver dma transaction counter pointer register r241 (f1h) receiver dma source address pointer register r242 (f2h) transmitter dma transaction counter pointer register r243 (f3h) transmitter dma destination address pointer register r244 (f4h) interrupt vector register r245 (f5h) address compare register r246 (f6h) interrupt mask register r247 (f7h) interrupt status register r248 (f8h) receive buffer register same address as transmitter buffer register (read only) r248 (f8h) transmitter buffer register same address as receive buffer register (write only) r249 (f9h) interrupt/dma priority register r250 (fah) character configuration register r251 (fbh) clock configuration register r252 (fch) baud rate generator high register r253 (fdh) baud rate generator low register r254 (feh) synchronous input control register r255 (ffh) synchronous output control register
165/224 st92163 - serial communications interface (sci) serial communications interface (cont'd) receiver dma counter pointer (rdcpr) r240 - read/write reset value: undefined bit 7:1 = rc[7:1] : receiver dma counter pointer. these bits contain the address of the receiver dma transaction counter in the register file. bit 0 = rr/m : receiver register file/memory se- lector . 0: select memory space as destination. 1: select the register file as destination. receiver dma address pointer (rdapr) r241 - read/write reset value: undefined bit 7:1 = ra[7:1] : receiver dma address pointer. these bits contain the address of the pointer (in the register file) of the receiver dma data source. bit 0 = rps : receiver dma memory pointer se- lector. this bit is only significant if memory has been se- lected for dma transfers (rr/m = 0 in the rdcpr register). 0: select isr register for receiver dma transfers address extension. 1: select dmasr register for receiver dma trans- fers address extension. transmitter dma counter pointer (tdcpr) r242 - read/write reset value: undefined bit 7:1 = tc[7:1] : transmitter dma counter point- er . these bits contain the address of the transmitter dma transaction counter in the register file. bit 0 = tr/m : transmitter register file/memory selector . 0: select memory space as source. 1: select the register file as source. transmitter dma address pointer (tdapr) r243 - read/write reset value: undefined bit 7:1 = ta[7:1] : transmitter dma address point- er. these bits contain the address of the pointer (in the register file) of the transmitter dma data source. bit 0 = tps : transmitter dma memory pointer se- lector. this bit is only significant if memory has been se- lected for dma transfers (tr/m = 0 in the tdcpr register). 0: select isr register for transmitter dma transfers address extension. 1: select dmasr register for transmitter dma transfers address extension. 70 rc7 rc6 rc5 rc4 rc3 rc2 rc1 rr/m 70 ra7 ra6 ra5 ra4 ra3 ra2 ra1 rps 70 tc7 tc6 tc5 tc4 tc3 tc2 tc1 tr/m 70 ta7 ta6 ta5 ta4 ta3 ta2 ta1 tps
166/224 st92163 - serial communications interface (sci) serial communications interface (cont'd) interrupt vector register (s_ivr) r244 - read/write reset value: undefined bit 7:3 = v[7:3] : sci interrupt vector base ad- dress. user programmable interrupt vector bits for trans- mitter and receiver. bit 2:1 = ev[2:1] : encoded interrupt source. both bits ev2 and ev1 are read only and set by hardware according to the interrupt source. bit 0 = d0 : this bit is forced by hardware to 0. address/data compare register (acr) r245 - read/write reset value: undefined bit 7:0 = ac[7:0] : address/compare character . with either 9th bit address mode, address after break mode, or character search, the received ad- dress will be compared to the value stored in this register. when a valid address matches this regis- ter content, the receiver address pending bit (rxap in the s_isr register) is set. after the rxap bit is set in an addressed mode, all received data words will be transferred to the receiver buff- er register. 70 v7 v6 v5 v4 v3 ev2 ev1 0 ev2 ev1 interrupt source 0 0 receiver error (overrun, framing, parity) 0 1 break detect or address match 10 received data pending/receiver dma end of block 11 transmitter buffer or shift register empty transmitter dma end of block 70 ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0
167/224 st92163 - serial communications interface (sci) serial communications interface (cont'd) interrupt mask register (imr) r246 - read/write reset value: 0xx00000 bit 7 = bsn : buffer or shift register empty inter- rupt . this bit selects the source of the transmitter regis- ter empty interrupt. 0: select a shift register empty as source of a transmitter register empty interrupt. 1: select a buffer register empty as source of a transmitter register empty interrupt. bit 6 = rxeob : received end of block. this bit is set by hardware only and must be reset by software. rxeob is set after a receiver dma cycle to mark the end of a data block. 0: clear the interrupt request. 1: mark the end of a received block of data. bit 5 = txeob : transmitter end of block. this bit is set by hardware only and must be reset by software. txeob is set after a transmitter dma cycle to mark the end of a data block. 0: clear the interrupt request. 1: mark the end of a transmitted block of data. bit 4 = rxe : receiver error mask. 0: disable receiver error interrupts (oe, pe, and fe pending bits in the s_isr register). 1: enable receiver error interrupts. bit 3 = rxa : receiver address mask . 0: disable receiver address interrupt (rxap pending bit in the s_isr register). 1: enable receiver address interrupt. bit 2 = rxb : receiver break mask . 0: disable receiver break interrupt (rxbp pend- ing bit in the s_isr register). 1: enable receiver break interrupt. bit 1 = rxdi : receiver data interrupt mask . 0: disable receiver data pending and receiver end of block interrupts (rxdp and rxeob pending bits in the s_isr register). 1: enable receiver data pending and receiver end of block interrupts. note: rxdi has no effect on dma transfers. bit 0 = txdi : transmitter data interrupt mask . 0: disable transmitter buffer register empty, transmitter shift register empty, or transmitter end of block interrupts (txbem, txsem, and txeob bits in the s_isr register). 1: enable transmitter buffer register empty, transmitter shift register empty, or transmitter end of block interrupts. note: txdi has no effect on dma transfers. 70 bsn rxeob txeob rxe rxa rxb rxdi txdi
168/224 st92163 - serial communications interface (sci) serial communications interface (cont'd) interrupt status register (s_isr) r247 - read/write reset value: undefined bit 7 = oe : overrun error pending . this bit is set by hardware if the data in the receiv- er buffer register was not read by the cpu before the next character was transferred into the receiv- er buffer register (the previous data is lost). 0: no overrun error. 1: overrun error occurred. bit 6 = fe : framing error pending bit . this bit is set by hardware if the received data word did not have a valid stop bit. 0: no framing error. 1: framing error occurred. note: in the case where a framing error occurs when the sci is programmed in address mode and is monitoring an address, the interrupt is as- serted and the corrupted data element is trans- ferred to the receiver buffer register. bit 5 = pe : parity error pending . this bit is set by hardware if the received word did not have the correct even or odd parity bit. 0: no parity error. 1: parity error occurred. bit 4 = rxap : receiver address pending . rxap is set by hardware after an interrupt ac- knowledged in the address mode. 0: no interrupt in address mode. 1: interrupt in address mode occurred. note: the source of this interrupt is given by the couple of bits (amen, am) as detailed in the idpr register description. bit 3 = rxbp : receiver break pending bit . this bit is set by hardware if the received data in- put is held low for the full word transmission time (start bit, data bits, parity bit, stop bit). 0: no break received. 1: break event occurred. bit 2 = rxdp : receiver data pending bit. this bit is set by hardware when data is loaded into the receiver buffer register. 0: no data received. 1: data received in receiver buffer register. bit 1 = txbem : transmitter buffer register emp- ty . this bit is set by hardware if the buffer register is empty. 0: no buffer register empty event. 1: buffer register empty. bit 0 = txsem : transmitter shift register empty . this bit is set by hardware if the shift register has completed the transmission of the available data. 0: no shift register empty event. 1: shift register empty. note: the interrupt status register bits can be re- set but cannot be set by the user. the interrupt source must be cleared by resetting the related bit when executing the interrupt service routine (natu- rally the other pending bits should not be reset). 70 oe fe pe rxap rxbp rxdp txbe m txsem
169/224 st92163 - serial communications interface (sci) serial communications interface (cont'd) receiver buffer register (rxbr) r248 - read only reset value: undefined bit 7:0 = rd[7:0] : received data. this register stores the data portion of the re- ceived word. the data will be transferred from the receiver shift register into the receiver buffer register at the end of the word. all receiver inter- rupt conditions will be updated at the time of trans- fer. if the selected character format is less than 8 bits, unused most significant bits will forced to a1o. note: rxbr and txbr are two physically differ- ent registers located at the same address. transmitter buffer register (txbr) r248 - write only reset value: undefined bit 7:0 = td[7:0] : transmit data . the st9 core will load the data for transmission into this register. the sci will transfer the data from the buffer into the shift register when availa- ble. at the transfer, the transmitter buffer register interrupt is updated. if the selected word format is less than 8 bits, the unused most significant bits are not significant. note: txbr and rxbr are two physically differ- ent registers located at the same address. 70 rd7 rd6 rd5 rd4 rd3 rd2 rd1 rd0 70 td7 td6 td5 td4 td3 td2 td1 td0
170/224 st92163 - serial communications interface (sci) serial communications interface (cont'd) interrupt/dma priority register (idpr) r249 - read/write reset value: undefined bit 7 = amen : address mode enable. this bit, together with the am bit (in the chcr reg- ister), decodes the desired addressing/9th data bit/character match operation. in address mode the sci monitors the input serial data until its address is detected note: upon reception of address, the rxap bit (in the interrupt status register) is set and an inter- rupt cycle can begin. the address character will not be transferred into the receiver buffer regis- ter but all data following the matched sci address and preceding the next address word will be trans- ferred to the receiver buffer register and the proper interrupts updated. if the address does not match, all data following this unmatched address will not be transferred to the receiver buffer reg- ister. in any of the cases the rxap bit must be reset by software before the next word is transferred into the buffer register. when amen is reset and am is set, a useful char- acter search function is performed. this allows the sci to generate an interrupt whenever a specific character is encountered (e.g. carriage return). bit 6 = sb : set break . 0: stop the break transmission after minimum break length. 1: transmit a break following the transmission of all data in the transmitter shift register and the buffer register. note: the break will be a low level on the transmit- ter data output for at least one complete word for- mat. if software does not reset sb before the min- imum break length has finished, the break condi- tion will continue until software resets sb. the sci terminates the break condition with a high level on the transmitter data output for one transmission clock period. bit 5 = sa : set address . if an address/9th data bit mode is selected, sa val- ue will be loaded for transmission into the shift register. this bit is cleared by hardware after its load. 0: indicate it is not an address word. 1: indicate an address word. note: proper procedure would be, when the transmitter buffer register is empty, to load the value of sa and then load the data into the trans- mitter buffer register. bit 4 = rxd : receiver dma mask . this bit is reset by hardware when the transaction counter value decrements to zero. at that time a receiver end of block interrupt can occur. 0: disable receiver dma request (the rxdp bit in the s_isr register can request an interrupt). 1: enable receiver dma request (the rxdp bit in the s_isr register can request a dma transfer). bit 3 = txd : transmitter dma mask . this bit is reset by hardware when the transaction counter value decrements to zero. at that time a transmitter end of block interrupt can occur. 0: disable transmitter dma request (txbem or txsem bits in s_isr can request an interrupt). 1: enable transmitter dma request (txbem or txsem bits in s_isr can request a dma trans- fer). bit 2:0 = prl[2:0] : sci interrupt/dma priority bits . the priority for the sci is encoded with (prl2,prl1,prl0). priority level 0 is the highest, while level 7 represents no priority. when the user has defined a priority level for the sci, priorities within the sci are hardware defined. these sci internal priorities are: 70 amen sb sa rxd txd prl2 prl1 prl0 amen am 0 0 address interrupt if 9th data bit = 1 0 1 address interrupt if character match 10 address interrupt if character match and 9th data bit =1 11 address interrupt if character match with word immediately following break receiver dma request highest priority transmitter dma request receiver interrupt transmitter interrupt lowest priority
171/224 st92163 - serial communications interface (sci) serial communications interface (cont'd) character configuration register (chcr) r250 - read/write reset value: undefined bit 7 = am : address mode . this bit, together with the amen bit (in the idpr register), decodes the desired addressing/9th data bit/character match operation. please refer to the table in the idpr register description. bit 6 = ep : even parity . 0: select odd parity (when parity is enabled). 1: select even parity (when parity is enabled). bit 5 = pen : parity enable . 0: no parity bit. 1: parity bit generated (transmit data) or checked (received data). note: if the address/9th bit is enabled, the parity bit will precede the address/9th bit (the 9th bit is never included in the parity calculation). bit 4 = ab : address/9th bit . 0: no address/9th bit. 1: address/9th bit included in the character format between the parity bit and the first stop bit. this bit can be used to address the sci or as a ninth data bit. bit 3:2 = sb[1:0] : number of stop bits .. bit 1:0 = wl[1:0] : number of data bits 70 am ep pen ab sb1 sb0 wl1 wl0 sb1 sb0 number of stop bits in 16x mode in 1x mode 00 1 1 0 1 1.5 2 10 2 2 1 1 2.5 3 wl1 wl0 data length 0 0 5 bits 0 1 6 bits 1 0 7 bits 1 1 8 bits
172/224 st92163 - serial communications interface (sci) serial communications interface (cont'd) clock configuration register (ccr) r251 - read/write reset value: 0000 0000 (00h) bit 7 = xtclk this bit, together with the oclk bit, selects the source for the transmitter clock. the following ta- ble shows the coding of xtclk and oclk. bit 6 = oclk this bit, together with the xtclk bit, selects the source for the transmitter clock. the following ta- ble shows the coding of xtclk and oclk. bit 5 = xrx : external receiver clock source . 0: external receiver clock source not used. 1: select the external receiver clock source. note: the external receiver clock frequency must be 16 times the data rate, or equal to the data rate, depending on the status of the cd bit. bit 4 = xbrg : baud rate generator clock source . 0: select intclk for the baud rate generator. 1: select the external receiver clock for the baud rate generator. bit 3 = cd : clock divisor . the status of cd will determine the sci configura- tion (synchronous/asynchronous). 0: select 16x clock mode for both receiver and transmitter. 1: select 1x clock mode for both receiver and transmitter. note: in 1x clock mode, the transmitter will trans- mit data at one data bit per clock period. in 16x mode each data bit period will be 16 clock periods long. bit 2 = aen : auto echo enable . 0: no auto echo mode. 1: put the sci in auto echo mode. note: auto echo mode has the following effect: the sci transmitter is disconnected from the data- out pin sout, which is driven directly by the re- ceiver data-in pin, sin. the receiver remains con- nected to sin and is operational, unless loopback mode is also selected. bit 1 = lben : loopback enable . 0: no loopback mode. 1: put the sci in loopback mode. note: in this mode, the transmitter output is set to a high level, the receiver input is disconnected, and the output of the transmitter shift register is looped back into the receiver shift register input. all interrupt sources (transmitter and receiver) are operational. bit 0 = stpen : stick parity enable . 0: the transmitter and the receiver will follow the parity of even parity bit ep in the chcr register. 1: the transmitter and the receiver will use the op- posite parity type selected by the even parity bit ep in the chcr register. 70 xtclk oclk xrx xbrg cd aen lben stpe n xtclk oclk pin function 0 0 pin is used as a general i/o 0 1 pin = txclk (used as an input) 10 pin = clkout (outputs the baud rate generator clock) 11 pin = clkout (outputs the serial expansion and synchronous mode clock) ep spen parity (transmitter & receiver) 0 (odd) 0 odd 1 (even) 0 even 0 (odd) 1 even 1 (even) 1 odd
173/224 st92163 - serial communications interface (sci) serial communications interface (cont'd) baud rate generator high register (brghr) r252 - read/write reset value: undefined baud rate generator low register (brglr) r253 - read/write reset value: undefined bit 15:0 = baud rate generator msb and lsb. the baud rate generator is a programmable di- vide by ano counter which can be used to generate the clocks for the transmitter and/or receiver. this counter divides the clock input by the value in the baud rate generator register. the minimum baud rate divisor is 2 and the maximum divisor is 2 16 -1. after initialization of the baud rate genera- tor, the divisor value is immediately loaded into the counter. this prevents potentially long random counts on the initial load. if set to 0 or 1, the baud rate generator is stopped. synchronous input control (sicr) r254 - read/write reset value: 0000 0011 (03h) bit 7 = smen : synchronous mode enable . 0: disable all features relating to synchronous mode (the contents of sicr and socr are ig- nored). 1: select synchronous mode with its programmed i/o configuration. bit 6 = inpl : sin input polarity . 0: polarity not inverted. 1: polarity inverted. note: inpl only affects received data. in auto- echo mode sout = sin even if inpl is set. in loop-back mode the state of the inpl bit is irrele- vant. bit 5 = xckpl : receiver clock polarity . 0: rxclk is active on the rising edge. 1: rxclk is active on the falling edge. note: xckpl only affects the receiver clock. in auto-echo mode clkout = rxclk independ- ently of the xckpl status. in loop-back the state of the xckpl bit is irrelevant. bit 4 = dcden : dcd input enable . 0: disable hardware synchronization. 1: enable hardware synchronization. note: when dcden is set, rxclk drives the re- ceiver section only during the active level of the dcd input (dcd works as a gate on rxclk, in- forming the mcu that a transmitting device is sending a synchronous frame to it). bit 3 = dcdpl : dcd input polarity . 0: the dcd input is active when low. 1: the dcd input is active when high. note: dcdpl only affects the gating activity of the receiver clock. in auto-echo mode rts = dcd in- dependently of dcdpl. in loop-back mode, the state of dcdpl is irrelevant. bit 2 = inpen : all input disable . 0: enable sin/rxclk/dcd inputs. 1: disable sin/rxclk/dcd inputs. bit 1:0 = adon't careo 15 8 bg15 bg14 bg13 bg12 bg11 bg10 bg9 bg8 70 bg7 bg6 bg5 bg4 bg3 bg2 bg1 bg0 70 smen inpl xckpl dcde n dcdp l inpen x x
174/224 st92163 - serial communications interface (sci) serial communications interface (cont'd) synchronous output control (socr) r255 - read/write reset value: 0000 0001 (01h) bit 7 = outpl : sout output polarity. 0: polarity not inverted. 1: polarity inverted. note: outpl only affects the data sent by the transmitter section. in auto-echo mode sout = sin even if outpl=1. in loop-back mode, the state of outpl is irrelevant. bit 6 = outsb : sout output stand-by level . 0: sout stand-by level is high. 1: sout stand-by level is low. bit 5 = ockpl : transmitter clock polarity. 0: clkout is active on the rising edge. 1: clkout is active on the falling edge. note: ockpl only affects the transmitter clock. in auto-echo mode clkout = rxclk independ- ently of the state of ockpl. in loop-back mode the state of ockpl is irrelevant. bit 4 = ocksb : transmitter clock stand-by lev- el. 0: the clkout stand-by level is high. 1: the clkout stand-by level is low. bit 3 = rtsen : rts and sds output enable . 0: disable the rts and sds hardware synchroni- sation. 1: enable the rts and sds hardware synchroni- sation. notes: when rtsen is set, the rts output becomes active just before the first active edge of clk- out and indicates to target device that the mcu is about to send a synchronous frame; it returns to its stand-by value just after the last active edge of clkout (msb transmitted). when rtsen is set, the sds output becomes active high and indicates to the target device that the mcu is about to send the first bit of a syn- chronous frame on the serial output pin (sout); it returns to low level as soon as the second bit is sent on the serial output pin (sout). in this way a positive pulse is generated each time that the first bit of a synchronous frame is present on the serial output pin (sout). bit 2 = rtspl : rts output polarity. 0: the rts output is active when low. 1: the rts output is active when high. note: rtspl only affects the rts activity on the output pin. in auto-echo mode rts = dcd inde- pendently from the rtspl value. in loop-back mode rtspl value is 'don't care'. bit 1 = outdis : disable all outputs. this feature is available on specific devices only (see device pin-out description). when outdis=1, all output pins (if configured in alternate function mode) will be put in high im- pedance for networking. 0: sout/clkout/enabled 1: sout/clkout/rts put in high impedance bit 0 = adon't careo 70 outp l outs b ockp l ocks b rtse n rts pl out dis x
175/224 st92163 - i2c bus interface 8.5 i 2 c bus interface 8.5.1 introduction the i 2 c bus interface serves as an interface be- tween the microcontroller and the serial i 2 c bus. it provides both multimaster and slave functions with both 7-bit and 10-bit address modes; it controls all i 2 c bus-specific sequencing, protocol, arbitration, timing and supports both standard (100khz) and fast i 2 c modes (400khz). using dma, data can be transferred with minimum use of cpu time. the peripheral uses two external lines to perform the protocols: sda, scl. 8.5.2 main features n parallel-bus/i 2 c protocol converter n multi-master capability n 7-bit/10-bit addressing n standard i 2 c mode/fast i 2 c mode n transmitter/receiver flag n end-of-byte transmission flag n transfer problem detection n interrupt generation on error conditions n interrupt generation on transfer request and on data received i 2 c master features: n start bit detection flag n clock generation n i 2 c bus busy flag n arbitration lost flag n end of byte transmission flag n transmitter/receiver flag n stop/start generation i 2 c slave features: n stop bit detection n i 2 c bus busy flag n detection of misplaced start or stop condition n programmable i 2 c address detection (both 7- bit and 10-bit mode) n general call address programmable n transfer problem detection n end of byte transmission flag n transmitter/receiver flag. interrupt features: n interrupt generation on error condition, on transmission request and on data received n interrupt address vector for each interrupt source n pending bit and mask bit for each interrupt source n programmable interrupt priority respects the other peripherals of the microcontroller n interrupt address vector programmable dma features: n dma both in transmission and in reception with enabling bits n dma from/toward both register file and memory n end of block interrupt sources with the related pending bits n selection between dma suspended and dma not-suspended mode if error condition occurs.
176/224 st92163 - i2c bus interface i 2 c interface (cont'd) figure 82. i 2 c interface block diagram 8.5.3 functional description refer to the i2ccr, i2csr1 and i2csr2 registers in section 8.5.7. for the bit definitions. the i 2 c interface works as an i/o interface between the st9 microcontroller and the i 2 c bus protocol. in addition to receiving and transmitting data, the interface converts data from serial to parallel format and vice versa using an interrupt or polled handshake. it operates in multimaster/slave i 2 c mode. the se- lection of the operating mode is made by software. the i 2 c interface is connected to the i 2 c bus by a data pin (sdai) and a clock pin (scli) which must be configured as open drain when the i 2 c cell is enabled by programming the i/o port bits and the pe bit in the i2ccr register. in this case, the value of the external pull-up resistance used depends on the application. when the i 2 c cell is disabled, the sdai and scli ports revert to being standard i/ o port pins. the i 2 c interface has sixteen internal registers. six of them are used for initialization: own address registers i2coar1, i2coar2 general call address register i2cadr clock control registers i2cccr, i2ceccr control register i2ccr the following four registers are used during data transmission/reception: data register i2cdr control register i2ccr status register 1 i2csr1 status register 2 i2csr2 data registe r data shift register compara tor own address register 2 clock control register status registe r 1 control registe r control data clock control sdai scli logic and interrupt/ dma registers general call address status registe r 2 dma data bus control signals interrupt vr02119a sda scl own addres s registe r 1
177/224 st92163 - i2c bus interface i 2 c interface (cont'd) the following seven registers are used to handle the interrupt and the dma features: interrupt status register i2cisr interrupt mask register i2cimr interrupt vector register i2civr receiver dma address pointer register i2crdap receiver dma transaction counter register i2crdc transmitter dma address pointer register i2ctdap transmitter dma transaction counter register i2ctdc the interface can decode both addresses: software programmable 7-bit general call address i 2 c address stored by software in the i2coar1 register in 7-bit address mode or stored in i2coar1 and i2coar2 registers in 10-bit ad- dress mode. after a reset, the interface is disabled. important : 1. to guarantee correct operation, before enabling the peripheral (while i2ccr.pe=0), configure bit7 and bit6 of the i2coar2 register according to the internal clock intclk (for example 11xxxxxxb in the range 14 - 30 mhz). 2. bit7 of the i2ccr register must be cleared. 8.5.3.1 mode selection i ni 2 c mode, the interface can operate in the four following modes: master transmitter/receiver slave transmitter/receiver by default, it operates in slave mode. this interface automatically switches from slave to master after a start condition is generated on the bus and from master to slave in case of arbitration loss or stop condition generation. in master mode, it initiates a data transfer and generates the clock signal. a serial data transfer always begins with a start condition and ends with a stop condition. both start and stop conditions are generated in master mode by software. in slave mode, it is able to recognize its own ad- dress (7 or 10-bit), as stored in the i2coar1 and i2coar2 registers and (when the i2ccr.engc bit is set) the general call address (stored in i2cadr register). it never recognizes the start byte (address byte 01h) whatever its own address is. data and addresses are transferred in 8 bits, msb first. the first byte(s) following the start condition contain the address (one byte in 7-bit mode, two bytes in 10-bit mode). the address is always transmitted in master mode. a 9th clock pulse follows the 8 clock cycles of a byte transfer, during which the receiver must send an acknowledge bit to the transmitter. acknowledge is enabled and disabled by software. refer to figure 83.
178/224 st92163 - i2c bus interface i2c interface (cont'd) figure 83. i 2 c bus protocol any transfer can be done using either the i 2 c registers directly or via the dma. if the transfer is to be done directly on i 2 c, the interface waits (by holding the scl line low) for software to write in the data register before transmission of a data byte, or to read the data register after a data byte is received. if the transfer is to be done via dma, the interface sends a request for a dma transfer. then it waits for the dma to complete. the transfer between the interface and the i 2 c bus will begin on the next rising edge of the scl clock. the scl frequency (f scl ) generated in master mode is controlled by a programmable clock divid- er. the speed of the i 2 c interface may be selected between standard (0-100khz) and fast (100- 400khz) i 2 c modes. 8.5.4 i 2 c state machine to enable the interface in i 2 c mode the i2ccr.pe bit must be set twice as the first write only acti- vates the interface (only the pe bit is set); and the bit7 of i2ccr register must be cleared. the i 2 c interface always operates in slave mode (the m/sl bit is cleared) except when it initiates a transmission or a receipt sequencing (master mode). the multimaster function is enabled with an auto- matic switch from master mode to slave mode when the interface loses the arbitration of the i 2 c bus. 8.5.4.1 i 2 c slave mode as soon as a start condition is detected, the address word is received from the sda line and sent to the shift register; then it is compared with the address of the interface or the general call address (if selected by software). note: in 10-bit addressing mode, the comparison includes the header sequence (11110xx0) and the two most significant bits of the address. n header (10-bit mode) or address (both 10-bit and 7-bit modes) not matched : the state machine is reset and waits for another start condition. n header matched (10-bit mode only): the interface generates an acknowledge pulse if the ack bit of the control register (i2ccr) is set. n address matched : the i2csr1.adsl bit is set and an acknowledge bit is sent to the master if the i2ccr.ack bit is set. an interrupt is sent to the microcontroller if the i2ccr.ite bit is set.then it waits for the microcontroller to read the i2csr1 register by holding the scl line low (see figure 84 transfer sequencing ev1). scl sda 12 8 9 msb ack stop start condition condition vr02119b
179/224 st92163 - i2c bus interface i 2 c interface (cont'd) next, depending on the data direction bit (least significant bit of the address byte), and after the generation of an acknowledge, the slave must go in sending or receiving mode. in 10-bit mode, after receiving the address se- quence the slave is always in receive mode. it will enter transmit mode on receiving a repeated start condition followed by the header sequence with matching address bits and the least significant bit set (11110xx1). slave receiver following the address reception and after i2csr1 register has been read, the slave receives bytes from the sda line into the shift register and sends them to the i2cdr register. after each byte it generates an acknowledge bit if the i2ccr.ack bit is set. when the acknowledge bit is sent, the i2csr1.btf flag is set and an interrupt is generat- ed if the i2ccr.ite bit is set (see figure 84 transfer sequencing ev2). then the interface waits for a read of the i2csr1 register followed by a read of the i2cdr register, or waits for the dma to complete; both holding the scl line low . slave transmitter following the address reception and after i2csr1 register has been read, the slave sends bytes from the i2cdr register to the sda line via the internal shift register. when the acknowledge bit is received, the i2ccr.btf flag is set and an interrupt is generated if the i2ccr.ite bit is set (see figure 84 transfer sequencing ev3). the slave waits for a read of the i2csr1 register followed by a write in the i2cdr register or waits for the dma to complete, both holding the scl line low . error cases berr : detection of a stop or a start condition during a byte transfer. the i2csr2.berr flag is set and an interrupt is generated if i2ccr.ite bit is set. if it is a stop then the state machine is reset. if it is a start then the state machine is reset and it waits for the new slave address on the bus. af : detection of a no-acknowledge bit. the i2csr2.af flag is set and an interrupt is ge- nerated if the i2ccr.ite bit is set. note : in both cases, scl line is not stretched low; however, the sda line, due to possible ?0? bits transmitted last, can remain low. it is then neces- sary to release both lines by software. other events adsl : detection of a start condition after an ac- knowledge time-slot. the state machine is reset and starts a new pro- cess. the i2csr1.adsl flag bit is set and an in- terrupt is generated if the i2ccr.ite bit is set. the scl line is stretched low. stopf : detection of a stop condition after an acknowledge time-slot. the state machine is reset. then the i2csr2.stopf flag is set and an interrupt is ge- nerated if the i2ccr.ite bit is set. how to release the sda / scl lines set and subsequently clear the i2ccr.stop bit while the i2csr1.btf bit is set; then the sda/ scl lines are released immediately after the transfer of the current byte. this will also reset the state machine; any subse- quent stop bit (ev4) will not be detected. 8.5.4.2 i 2 c master mode to switch from default slave mode to master mode a start condition generation is needed. setting the i2ccr.start bit while the i2csr1.busy bit is cleared causes the interface to generate a start condition. once the start condition is generated, the periph- eral is in master mode (i2csr1.m/sl=1) and i2csr1.sb (start bit) flag is set and an interrupt is generated if the i2ccr.ite bit is set (see figure 84 transfer sequencing ev5 event). the interface waits for a read of the i2csr1 regis- ter followed by a write in the i2cdr register with the slave address, holding the scl line low .
180/224 st92163 - i2c bus interface i 2 c interface (cont'd) then the slave address is sent to the sda line. in 7-bit addressing mode, one address byte is sent. in 10-bit addressing mode, sending the first byte including the header sequence causes the i2csr1.evf and i2csr1.add10 bits to be set by hardware with interrupt generation if the i2ccr.ite bit is set. then the master waits for a read of the i2csr1 register followed by a write in the i2cdr register, holding the scl line low (see figure 84 transfer sequencing ev9). then the second address byte is sent by the interface. after each address byte, an acknowledge clock pulse is sent to the scl line if the i2csr1.evf and i2csr1.add10 bit (if first header) i2csr2.addtx bit (if address or second hea- der) are set, and an interrupt is generated if the i2ccr.ite bit is set. the peripheral waits for a read of the i2csr1 reg- ister followed by a write into the control register (i2ccr) by holding the scl line low (see figure 84 transfer sequencing ev6 event). if there was no acknowledge (i2csr2.af=1), the master must stop or restart the communication (set the i2ccr.start or i2ccr.stop bits). if there was an acknowledge, the state machine enters a sending or receiving process according to the data direction bit (least significant bit of the ad- dress), the i2csr1.btf flag is set and an interrupt is generated if i2ccr.ite bit is set (see transfer sequencing ev7, ev8 events). if the master loses the arbitration of the bus there is no acknowledge, the i2csr2.af flag is set and the master must set the start or stop bit in the control register (i2ccr).the i2csr2.arlo flag is set, the i2csr1.m/sl flag is cleared and the proc- ess is reset. an interrupt is generated if i2ccr.ite is set. master transmitter: the master waits for the microcontroller to write in the data register (i2cdr) or it waits for the dma to complete both holding the scl line low (see transfer sequencing ev8). then the byte is received into the shift register and sent to the sda line. when the acknowledge bit is received, the i2csr1.btf flag is set and an interrupt is generated if the i2ccr.ite bit is set or the dma is requested. note: in 10-bit addressing mode, to switch the master to receiver mode, software must generate a repeated start condition and resend the header sequence with the least significant bit set (11110xx1). master receiver: the master receives a byte from the sda line into the shift register and sends it to the i2cdr regis- ter. it generates an acknowledge bit if the i2ccr.ack bit is set and an interrupt if the i2ccr.ite bit is set or a dma is requested (see transfer sequencing ev7 event). then it waits for the microcontroller to read the data register (i2cdr) or waits for the dma to complete both holding scl line low . error cases n berr : detection of a stop or a start condition during a byte transfer. the i2csr2.berr flag is set and an interrupt is generated if i2ccr.ite is set. n af : detection of a no acknowledge bit the i2csr2.af flag is set and an interrupt is generated if i2ccr.ite is set. n arlo : arbitration lost the i2csr2.arlo flag is set, the i2csr1.m/sl flag is cleared and the process is reset. an interrupt is generated if the i2ccr.ite bit is set. note : in all cases, to resume communications, set the i2ccr.start or i2ccr.stop bits. events generated by the i 2 c interface n stop condition when the i2ccr.stop bit is set, a stop condition is generated after the transfer of the current byte, the i2csr1.m/sl flag is cleared and the state machine is reset. no interrupt is generated in master mode at the detection of the stop condition. n start condition when the i2ccr.start bit is set, a start condition is generated as soon as the i 2 c bus is free. the i2csr1.sb flag is set and an interrupt is generated if the i2ccr.ite bit is set.
181/224 st92163 - i2c bus interface i 2 c interface (cont'd) figure 84. transfer sequencing 7-bit slave receiver: 7-bit slave transmitter: 7-bit master receiver: 7-bit master transmitter: 10-bit slave receiver: 10-bit slave transmitter: 10-bit master transmitter 10-bit master receiver: legend: s=start, sr = repeated start, p=stop, a=acknowledge, na=non-acknowledge, evx=event (with interrupt if ite=1) ev1: evf=1, adsl=1, cleared by reading sr1 register. ev2: evf=1, btf=1, cleared by reading sr1 register followed by reading dr register or when dma is complete. ev3: evf=1, btf=1, cleared by reading sr1 register followed by writing dr register or when dma is complete. ev3-1: evf=1, af=1, btf=1; af is cleared by reading sr1 register, btf is cleared by releasing the lines (stop=1, stop=0) or writing dr register (for example dr=ffh). note : if lines are released by stop=1, stop=0 the subsequent ev4 is not seen. ev4: evf=1, stopf=1, cleared by reading sr2 register. s address a data1 a data2 a ..... datan a p ev1 ev2 ev2 ev2 ev4 s address a data1 a data2 a .... . datan na p ev1 ev3 ev3 ev3 ev3-1 ev4 s address a data1 a data2 a .... . datan na p ev5 ev6 ev7 ev7 ev7 s address a data1 a data2 a .... . datan a p ev5 ev6 ev8 ev8 ev8 ev8 s header a address a data1 a ..... datan a p ev1 ev2 ev2 ev4 s r header a data1 a .... . datan a p ev1 ev3 ev3 ev3-1 ev4 s header a address a data1 a .... . datan a p ev5 ev9 ev6 ev8 ev8 ev8 s r header a data1 a .... . datan a p ev5 ev6 ev7 ev7
182/224 st92163 - i2c bus interface ev5: evf=1, sb=1, cleared by reading sr1 register followed by writing dr register. ev6: evf=1, addtx=1, cleared by reading sr1 register followed by writing cr register (for example pe=1). ev7: evf=1, btf=1, cleared by reading sr1 register followed by reading dr register or when dma is complete. ev8: evf=1, btf=1, cleared by reading sr1 register followed by writing dr register or when dma is complete. ev9 : evf=1, add10=1, cleared by reading sr1 register followed by writing dr register. figure 85. event flags and interrupt generation adsl sb af stopf arlo berr add10 addtx ite ierrm ierrp error interrupt request btf=1 & tra=0 receiving dma ite irxm irxp data received interrupt request end of block or end of block btf=1 & tra=1 ite ready to transmit interrupt request or end of block i2csr1.evf reobp itxm itxp teobp transmitting dma end of block
183/224 st92163 - i2c bus interface i 2 c interface (cont'd) 8.5.5 interrupt features the i 2 cbus interface has three interrupt sources related to aerror conditiono, aperipheral ready to transmito and adata receivedo. the peripheral uses the st9+ interrupt internal protocol without requiring the use of the external interrupt channel. dedicated registers of the pe- ripheral should be loaded with appropriate values to set the interrupt vector (see the description of the i2civr register), the interrupt mask bits (see the description of the i2cimr register) and the in- terrupt priority and pending bits (see the descrip- tion of the i2cisr register). the peripheral also has a global interrupt enable (the i2ccr.ite bit) that must be set to enable the interrupt features. moreover there is a global inter- rupt flag that is set when one of the interrupt events occurs (except the end of block interrupts - see the dma features section). the adata receivedo interrupt source occurs after the acknowledge of a received data byte is per- formed. it is generated when the i2csr1.btf flag is set and the i2csr1.tra flag is zero. if the dma feature is enabled in receiver mode, this interrupt is not generated and the same inter- rupt vector is used to send a receiving end of block interrupt (see the dma feature section). the aperipheral ready to transmito interrupt source occurs as soon as a data byte can be transmitted by the peripheral. it is generated when the i2csr1.btf and the i2csr1.tra flags are set. if the dma feature is enabled in transmitter mode, this interrupt is not generated and the same inter- rupt vector is used to send a transmitting end of block interrupt (see the dma feature section). the aerror conditiono interrupt source occurs when one of the following condition occurs: address matched in slave mode while i2ccr.ack=1 (i2csr1.adsl and i2csr1.evf flags = 1) start condition generated (i2csr1.sb and i2csr1.evf flags = 1) no acknowledge received after byte transmis- sion (i2csr2.af and i2csr1.evf flags = 1) stop detected in slave mode (i2csr2.stopf and i2csr1.evf flags = 1) arbitration lost in master mode (i2csr2.arlo and i2csr1.evf flags = 1) bus error, start or stop condition detected during data transfer (i2csr2.berr and i2csr1.evf flags = 1) master has sent the header byte (i2csr1.add10 and i2csr1.evf flags = 1) address byte successfully transmitted in master mode. (i2csr1.evf = 1 and i2csr2.addtx=1) note: depending on the value of i2cisr.dmas- top bit, the pending bit related to the aerror condi- tiono interrupt source is able to suspend or not sus- pend dma transfers. each interrupt source has a dedicated interrupt address pointer vector stored in the i2civr regis- ter. the five more significant bits of the vector ad- dress are programmable by the customer, where- as the three less significant bits are set by hard- ware depending on the interrupt source: 010: error condition detected 100: data received 110: peripheral ready to transmit the priority with respect to the other peripherals is programmable by setting the prl[2:0] bits in the i2cisr register. the lowest interrupt priority is ob- tained by setting all the bits (this priority level is never acknowledged by the cpu and is equivalent to disabling the interrupts of the peripheral); the highest interrupt priority is programmed by reset- ting all the bits. see the interrupt and dma chap- ters for more details. the internal priority of the interrupt sources of the peripheral is fixed by hardware with the following order: aerror conditiono (highest priority), adata receivedo, aperipheral ready to transmito. note: the dma has the highest priority over the interrupts; moreover the atransmitting end of blocko interrupt has the same priority as the ape- ripheral ready to transmito interrupt and the are- ceiving end of blocko interrupt has the same prior- ity as the adata receivedo interrupt. each of these three interrupt sources has a pend- ing bit (ierrp, irxp, itxp) in the i2cisr register that is set by hardware when the corresponding in- terrupt event occurs. an interrupt request is per- formed only if the corresponding mask bit is set (ierrm, irxm, itxm) in the i2cimr register and the peripheral has a proper priority level. the pending bit has to be reset by software.
184/224 st92163 - i2c bus interface i 2 c interface (cont'd) note : until the pending bit is reset (while the cor- responding mask bit is set), the peripheral proc- esses an interrupt request. so, if at the end of an interrupt routine the pending bit is not reset, anoth- er interrupt request is performed. note : before the end of the transmission and re- ception interrupt routines, the i2csr1.btf flag bit should be checked, to acknowledge any interrupt requests that occurred during the interrupt routine and to avoid masking subsequent interrupt re- quests. note: the aerroro event interrupt pending bit (i2cisr.ierrp) is forced high until the error event flags are set (add10, adsl and sb flags of the i2csr1 register; sclf, addtx, af, stopf, arlo and berr flags of the i2csr2 register). note: if the i2cisr.dmastop bit is reset, then the dma has the highest priority with respect to the interrupts; if the bit is set (as after the mcu re- set) and the aerror evento pending bit is set (i2cisr.ierrp), then the dma is suspended until the pending bit is reset by software. in the second case, the aerroro interrupt sources have higher pri- ority, followed by dma, adata receivedo and are- ceiving end of blocko interrupts, aperipheral ready to transmito and atransmitting end of blocko. moreover the transmitting end of block interrupt has the same priority as the aperipheral ready to transmito interrupt and the receiving end of block interrupt has the same priority as the adata receivedo interrupt. 8.5.6 dma features the peripheral can use the st9+ on-chip direct memory access (dma) channels to provide high- speed data transaction between the peripheral and contiguous locations of register file, and memory. the transactions can occur from and to- ward the peripheral. the maximum number of transactions that each dma channel can perform is 222 if the register file is selected or 65536 if memory is selected. the control of the dma fea- tures is performed using registers placed in the pe- ripheral register page (i2cisr, i2cimr, i2crdap, i2crdc, i2ctdap, i2ctdc). each dma transfer consists of three operations: a load from/to the peripheral data register (i2cdr) to/from a location of register file/mem- ory addressed through the dma address regis- ter (or register pair) a post-increment of the dma address register (or register pair) a post-decrement of the dma transaction coun- ter, which contains the number of transactions that have still to be performed. depending on the value of the ddcisr.dmas- top bit the dma feature can be suspended or not (both in transmission and in reception) until the pending bit related to the aerror evento interrupt re- quest is set. the priority level of the dma features of the i 2 c interface with respect to the other peripherals and the cpu is the same as programmed in the i2cisr register for the interrupt sources. in the in- ternal priority level order of the peripheral, if dd- cisr.dmastop=0, dma has a higher priority with respect to the interrupt sources. otherwise (if ddcisr.dmastop=1), the dma has a priority lower than aerroro event interrupt sources but greater than reception and transmission interrupt sources. refer to the interrupt and dma chapters for details on the priority levels. the dma features are enabled by setting the cor- responding enabling bits (rxdm, txdm) in the i2cimr register. it is possible to select also the di- rection of the dma transactions. once the dma transfer is completed (the transac- tion counter reaches 0 value), an interrupt request to the cpu is generated. this kind of interrupt is called aend of blocko. the peripheral sends two different aend of blocko interrupts depending on the direction of the dma (receiving end of block - transmitting end of block). these interrupt sources have dedicated interrupt pending bits in the i2cimr register (reobp, teobp) and they are mapped on the same interrupt vectors as re- spectively adata receivedo and aperipheral ready to transmito interrupt sources. the same corre- spondence exists about the internal priority be- tween interrupts. note : the i2ccr.ite bit has no effect on the end of block interrupts. moreover, the i2csr1.evf flag is not set by the end of block interrupts.
185/224 st92163 - i2c bus interface i 2 c interface (cont'd) 8.5.6.1 dma between peripheral and register file if the dma transaction is made between the pe- ripheral and the register file, one register is required to hold the dma address and one to hold the dma transaction counter. these two registers must be located in the regis- ter file: the dma address register in the even ad- dressed register, the dma transaction counter in the following register (odd address). they are pointed to by the dma transaction counter pointer register (i2crdc register in re- ceiving, i2ctdc register in transmitting) located in the peripheral register page. in order to select the dma transaction with the register file, the control bit i2crdc.rf/mem in receiving mode or i2ctdc.rf/mem in transmit- ting mode must be set. the transaction counter register must be initial- ized with the number of dma transfers to perform and will be decremented after each transaction. the dma address register must be initialized with the starting address of the dma table in the regis- ter file, and it is increased after each transaction. these two registers must be located between ad- dresses 00h and dfh of the register file. when the dma occurs between peripheral and register file, the i2ctdap register (in transmis- sion) and the i2crdap one (in reception) are not used. 8.5.6.2 dma between peripheral and memory space if the dma transaction is made between the pe- ripheral and memory, a register pair is required to hold the dma address and another register pair to hold the dma transaction counter. these two pairs of registers must be located in the register file. the dma address pair is pointed to by the dma address pointer register (i2crdap register in reception, i2ctdap register in transmission) lo- cated in the peripheral register page; the dma transaction counter pair is pointed to by the dma transaction counter pointer register (i2crdc register in reception, i2ctdc register in transmis- sion) located in the peripheral register page. in order to select the dma transaction with the memory space, the control bit i2crdc.rf/mem in receiving mode or i2ctdc.rf/mem in transmit- ting mode must be reset. the transaction counter registers pair must be in- itialized with the number of dma transfers to per- form and will be decremented after each transac- tion. the dma address register pair must be ini- tialized with the starting address of the dma table in the memory space, and it is increased after each transaction. these two register pairs must be located between addresses 00h and dfh of the register file. 8.5.6.3 dma in master receive to correctly manage the reception of the last byte when the dma in master receive mode is used, the following sequence of operations must be per- formed: 1. the number of data bytes to be received must be set to the effective number of bytes minus one byte. 2. when the receiving end of block condition occurs, the i2ccr.stop bit must be set and the i2ccr.ack bit must be reset. the last byte of the reception sequence can be re- ceived either using interrupts/polling or using dma. if the user wants to receive the last byte us- ing dma, the number of bytes to be received must be set to 1, and the dma in reception must be re- enabled (imr.rxdm bit set) to receive the last byte. moreover the receiving end of block inter- rupt service routine must be designed to recognize and manage the two different end of block situa- tions (after the first sequence of data bytes and af- ter the last data byte).
186/224 st92163 - i2c bus interface i 2 c interface (cont'd) 8.5.7 register description important : 1. to guarantee correct operation, before enabling the peripheral (while i2ccr.pe=0), configure bit7 and bit6 of the i2coar2 register according to the internal clock intclk (for example 11xxxxxxb in the range 14 - 30 mhz). 2. bit7 of the i2ccr register must be cleared. i 2 c control register (i2ccr) r240 - read / write register page: 20 reset value: 0000 0000 (00h) bit 7:6 = reserved must be cleared bit 5 = pe peripheral enable. this bit is set and cleared by software. 0: peripheral disabled (reset value) 1: master/slave capability notes: when i2ccr.pe=0, all the bits of the i2ccr register and the i2csr1-i2csr2 registers ex- cept the stop bit are reset. all outputs will be re- leased while i2ccr.pe=0 when i2ccr.pe=1, the corresponding i/o pins are selected by hardware as alternate functions (open drain). to enable the i 2 c interface, write the i2ccr reg- ister twice with i2ccr.pe=1 as the first write only activates the interface (only i2ccr.pe is set). when pe=1, the freq[2:0] and en10bit bits in the i2coar2 and i2cadr registers cannot be written. the value of these bits can be changed only when pe=0. bit 4 = engc general call address enable. setting this bit the peripheral works as a slave and the value stored in the i2cadr register is recog- nized as device address. this bit is set and cleared by software. it is also cleared by hardware when the interface is disa- bled (i2ccr.pe=0). 0: the address stored in the i2cadr register is ignored (reset value) 1: the general call address stored in the i2cadr register will be acknowledged note: the correct value (usually 00h) must be written in the i2cadr register before enabling the general call feature. bit 3 = start generation of a start condition . this bit is set and cleared by software. it is also cleared by hardware when the interface is disa- bled (i2ccr.pe=0) or when the start condition is sent (with interrupt generation if ite=1). in master mode: 0: no start generation 1: repeated start generation in slave mode: 0: no start generation (reset value) 1: start generation when the bus is free bit 2 = ack acknowledge enable. this bit is set and cleared by software. it is also cleared by hardware when the interface is disa- bled (i2ccr.pe=0). 0: no acknowledge returned (reset value) 1: acknowledge returned after an address byte or a data byte is received bit 1 = stop generation of a stop condition . this bit is set and cleared by software. it is also cleared by hardware in master mode. it is not cleared when the interface is disabled (i2ccr.pe=0). in slave mode, this bit must be set only when i2csr1.btf=1. in master mode: 0: no stop generation 1: stop generation after the current byte transfer or after the current start condition is sent. the stop bit is cleared by hardware when the stop condition is sent. in slave mode: 0: no stop generation (reset value) 1: release scl and sda lines after the current byte transfer (i2csr1.btf=1). in this mode the stop bit has to be cleared by software. 70 0 0 pe engc start ack stop ite
187/224 st92163 - i2c bus interface i 2 c interface (cont'd) bit 0 = ite interrupt enable. the ite bit enables the generation of interrupts. this bit is set and cleared by software and cleared by hardware when the interface is disabled (i2ccr.pe=0). 0: interrupts disabled (reset value) 1: interrupts enabled after any of the following con- ditions: byte received or to be transmitted (i2csr1.btf and i2csr1.evf flags = 1) address matched in slave mode while i2ccr.ack=1 (i2csr1.adsl and i2csr1.evf flags = 1) start condition generated (i2csr1.sb and i2csr1.evf flags = 1) no acknowledge received after byte transmis- sion (i2csr2.af and i2csr1.evf flags = 1) stop detected in slave mode (i2csr2.stopf and i2csr1.evf flags = 1) arbitration lost in master mode (i2csr2.arlo and i2csr1.evf flags = 1) bus error, start or stop condition detected during data transfer (i2csr2.berr and i2csr1.evf flags = 1) master has sent header byte (i2csr1.add10 and i2csr1.evf flags = 1) address byte successfully transmitted in mas- ter mode. (i2csr1.evf = 1 and i2csr2.addtx = 1) scl is held low when the addtx flag of the i2csr2 register or the add10, sb, btf or adsl flags of i2csr1 register are set (see figure 84) or when the dma is not complete. the transfer is suspended in all cases except when the btf bit is set and the dma is enabled. in this case the event routine must suspend the dma transfer if it is required. i 2 c status register 1 (i2csr1) r241 - read only register page: 20 reset value: 0000 0000 (00h) note: some bits of this register are reset by a read operation of the register. care must be taken when using instructions that work on single bit. some of them perform a read of all the bits of the register before modifying or testing the wanted bit. so oth- er bits of the register could be affected by the op- eration. in the same way, the test/compare operations per- form a read operation. moreover, if some interrupt events occur while the register is read, the corresponding flags are set, and correctly read, but if the read operation resets the flags, no interrupt request occurs. bit 7 = evf event flag. this bit is set by hardware as soon as an event ( listed below or described in figure 84) occurs. it is cleared by software when all event conditions that set the flag are cleared. it is also cleared by hard- ware when the interface is disabled (i2ccr.pe=0). 0: no event 1: one of the following events has occurred: byte received or to be transmitted (i2csr1.btf and i2csr1.evf flags = 1) address matched in slave mode while i2ccr.ack=1 (i2csr1.adsl and i2csr1.evf flags = 1) start condition generated (i2csr1.sb and i2csr1.evf flags = 1) no acknowledge received after byte transmis- sion (i2csr2.af and i2csr1.evf flags = 1) stop detected in slave mode (i2csr2.stopf and i2csr1.evf flags = 1) arbitration lost in master mode (i2csr2.arlo and i2csr1.evf flags = 1) bus error, start or stop condition detected during data transfer (i2csr2.berr and i2csr1.evf flags = 1) master has sent header byte (i2csr1.add10 and i2csr1.evf flags = 1) 70 evf add10 tra busy btf adsl m/sl sb
188/224 st92163 - i2c bus interface i 2 c interface (cont'd) address byte successfully transmitted in mas- ter mode. (i2csr1.evf = 1 and i2csr2.addtx=1) bit 6 = add10 10-bit addressing in master mode. this bit is set when the master has sent the first byte in 10-bit address mode. an interrupt is gener- ated if ite=1. it is cleared by software reading i2csr1 register followed by a write in the i2cdr register of the second address byte. it is also cleared by hard- ware when peripheral is disabled (i2ccr.pe=0) or when the stopf bit is set. 0: no add10 event occurred. 1: master has sent first address byte (header). bit 5 = tra transmitter/ receiver. when btf flag of this register is set and also tra=1, then a data byte has to be transmitted. it is cleared automatically when btf is cleared. it is also cleared by hardware after the stopf flag of i2csr2 register is set, loss of bus arbitration (arlo flag of i2csr2 register is set) or when the interface is disabled (i2ccr.pe=0). 0: a data byte is received (if i2csr1.btf=1) 1: a data byte can be transmitted (if i2csr1.btf=1) bit 4 = busy bus busy . it indicates a communication in progress on the bus. the detection of the communications is al- ways active (even if the peripheral is disabled). this bit is set by hardware on detection of a start condition and cleared by hardware on detection of a stop condition. this information is still updated when the interface is disabled (i2ccr.pe=0). 0: no communication on the bus 1: communication ongoing on the bus bit 3 = btf byte transfer finished. this bit is set by hardware as soon as a byte is cor- rectly received or before the transmission of a data byte with interrupt generation if ite=1. it is cleared by software reading i2csr1 register followed by a read or write of i2cdr register or when dma is complete. it is also cleared by hardware when the interface is disabled (i2ccr.pe=0). following a byte transmission, this bit is set after reception of the acknowledge clock pulse. btf is cleared by reading i2csr1 register followed by writing the next byte in i2cdr register or when dma is complete. following a byte reception, this bit is set after transmission of the acknowledge clock pulse if ack=1. btf is cleared by reading i2csr1 reg- ister followed by reading the byte from i2cdr register or when dma is complete. the scl line is held low while i2csr1.btf=1. 0: byte transfer not done 1: byte transfer succeeded bit 2 = adsl address matched (slave mode). this bit is set by hardware if the received slave ad- dress matches the i2coar1/i2coar2 register content or a general call address. an interrupt is generated if ite=1. it is cleared by software reading i2csr1 register or by hardware when the interface is disabled (i2ccr.pe=0). the scl line is held low while adsl=1. 0: address mismatched or not received 1: received address matched bit 1 = m/sl master/slave. this bit is set by hardware as soon as the interface is in master mode (start condition generated on the lines after the i2ccr.start bit is set). it is cleared by hardware after detecting a stop condi- tion on the bus or a loss of arbitration (arlo=1). it is also cleared when the interface is disabled (i2ccr.pe=0). 0: slave mode 1: master mode bit 0 = sb start bit (master mode). this bit is set by hardware as soon as the start condition is generated (following a write of start=1 if the bus is free). an interrupt is gener- ated if ite=1. it is cleared by software reading i2csr1 register followed by writing the address byte in i2cdr register. it is also cleared by hard- ware when the interface is disabled (i2ccr.pe=0). the scl line is held low while sb=1. 0: no start condition 1: start condition generated
189/224 st92163 - i2c bus interface i 2 c interface (cont'd) i 2 c status register 2 (i2csr2) r242 - read only register page: 20 reset value: 0000 0000 (00h) note: some bits of this register are reset by a read operation of the register. care must be taken when using instructions that work on single bit. some of them perform a read of all the bits of the register before modifying or testing the wanted bit. so oth- er bits of the register could be affected by the op- eration. in the same way, the test/compare operations per- form a read operation. moreover, if some interrupt events occur while the register is read, the corresponding flags are set, and correctly read, but if the read operation resets the flags, no interrupt request occurs. bit 7:6 = reserved. forced to 0 by hardware. bit 5 = addtx address or 2nd header transmitted in master mode. this bit is set by hardware when the peripheral, enabled in master mode, has received the ac- knowledge relative to: address byte in 7-bit mode address or 2nd header byte in 10-bit mode. 0: no address or 2nd header byte transmitted 1: address or 2nd header byte transmitted. bit 4 = af acknowledge failure . this bit is set by hardware when no acknowledge is returned. an interrupt is generated if ite=1. it is cleared by software reading i2csr2 register after the falling edge of the acknowledge scl pulse , or by hardware when the interface is disa- bled (i2ccr.pe=0). the scl line is not held low while af=1. 0: no acknowledge failure detected 1: a data or address byte was not acknowledged bit 3 = stopf stop detection (slave mode). this bit is set by hardware when a stop condition is detected on the bus after an acknowledge. an interrupt is generated if ite=1. it is cleared by software reading i2csr2 register or by hardware when the interface is disabled (i2ccr.pe=0). the scl line is not held low while stopf=1. 0: no stop condition detected 1: stop condition detected ( while slave receiver ) bit 2 = arlo arbitration lost . this bit is set by hardware when the interface (in master mode) loses the arbitration of the bus to another master. an interrupt is generated if ite=1. it is cleared by software reading i2csr2 register or by hardware when the interface is disabled (i2ccr.pe=0). after an arlo event the interface switches back automatically to slave mode (m/sl=0). the scl line is not held low while arlo=1. 0: no arbitration lost detected 1: arbitration lost detected bit 1 = berr bus error. this bit is set by hardware when the interface de- tects a start or stop condition during a byte trans- fer. an interrupt is generated if ite=1. it is cleared by software reading i2csr2 register or by hardware when the interface is disabled (i2ccr.pe=0). the scl line is not held low while berr=1. note : if a misplaced start condition is detected, also the arlo flag is set; moreover, if a misplaced stop condition is placed on the acknowledge scl pulse, also the af flag is set. 0: no start or stop condition detected during byte transfer 1: start or stop condition detected during byte transfer bit 0 = gcal general call address matched. this bit is set by hardware after an address matches with the value stored in the i2cadr reg- ister while engc=1. in the i2cadr the general call address must be placed before enabling the peripheral. it is cleared by hardware after the detection of a stop condition, or when the peripheral is disabled (i2ccr.pe=0). 0: no match 1: general call address matched. 70 0 0 addtx af stopf arlo berr gcal
190/224 st92163 - i2c bus interface i 2 c interface (cont'd) i 2 c clock control register (i2cccr) r243 - read / write register page: 20 reset value: 0000 0000 (00h) bit 7 = fm/sm fast/standard i 2 c mode. this bit is used to select between fast and stand- ard mode. see the description of the following bits. it is set and cleared by software. it is not cleared when the peripheral is disabled (i2ccr.pe=0) bit 6:0 = cc[6:0] 9-bit divider programming implementation of a programmable clock divider. these bits and the cc[8:7] bits of the i2ceccr register select the speed of the bus (f scl ) de- pending on the i 2 c mode. they are not cleared when the interface is disa- bled (i2ccr.pe=0). standard mode (fm/sm=0): f scl <= 100khz f scl = intclk/(2x([cc8..cc0]+2)) fast mode (fm/sm=1): f scl > 100khz f scl = intclk/(3x([cc8..cc0]+2)) note: the programmed frequency is available with no load on scl and sda pins. i 2 c own address register 1 (i2coar1) r244 - read / write register page:20 reset value: 0000 0000 (00h) 7-bit addressing mode bit 7:1 = add[7:1] interface address . these bits define the i 2 c bus address of the inter- face. they are not cleared when the interface is disa- bled (i2ccr.pe=0). bit 0 = add0 address direction bit. this bit is don't care; the interface acknowledges either 0 or 1. it is not cleared when the interface is disabled (i2ccr.pe=0). note: address 01h is always ignored. 10-bit addressing mode bit 7:0 = add[7:0] interface address . these are the least significant bits of the i 2 cbus address of the interface. they are not cleared when the interface is disa- bled (i2ccr.pe=0). 70 fm/sm cc6 cc5 cc4 cc3 cc2 cc1 cc0 70 add7 add6 add5 add4 add3 add2 add1 add0
191/224 st92163 - i2c bus interface i 2 c interface (cont'd) i 2 c own address register 2 (i2coar2) r245 - read / write register page: 20 reset value: 0000 0000 (00h) bit 7:6,4 = freq[2:0] frequency bits. important: to guarantee correct operation, set these bits before enabling the interface (while i2ccr.pe=0). these bits can be set only when the interface is disabled (i2ccr.pe=0). to configure the interface to i 2 c specified delays, select the value corre- sponding to the microcontroller internal frequency intclk. note: if an incorrect value, with respect to the mcu internal frequency, is written in these bits, the timings of the peripheral will not meet the i 2 c bus standard requirements. note: the freq[2:0] = 101, 110, 111 configura- tions must not be used. bit 5 = en10bit enable 10-bit i 2 cbus mode . when this bit is set, the 10-bit i 2 cbus mode is en- abled. this bit can be written only when the peripheral is disabled (i2ccr.pe=0). 0: 7-bit mode selected 1: 10-bit mode selected bit 4:3 = reserved. bit 2:1 = add[9:8] interface address . these are the most significant bits of the i 2 cbus address of the interface (10-bit mode only). they are not cleared when the interface is disabled (i2ccr.pe=0). bit 0 = reserved. i 2 c data register (i2cdr) r246 - read / write register page: 20 reset value: 0000 0000 (00h) bit 7:0 = dr[7:0] i2c data. in transmitter mode: i2cdr contains the next byte of data to be trans- mitted. the byte transmission begins after the microcontroller has written in i2cdr or on the next rising edge of the clock if dma is complete. in receiver mode: i2cdr contains the last byte of data received. the next byte receipt begins after the i2cdr read by the microcontroller or on the next rising edge of the clock if dma is complete. general call address (i2cadr) r247 - read / write register page: 20 reset value: 1010 0000 (a0h) bit 7:0 = adr[7:0] interface address . these bits define the i 2 cbus general call address of the interface. it must be written with the correct value depending on the use of the peripheral.if the peripheral is used in i 2 c bus mode, the 00h value must be loaded as general call address. the customer could load the register with other values. the bits can be written only when the peripheral is disabled (i2ccr.pe=0) the adr0 bit is don't care; the interface acknowl- edges either 0 or 1. note: address 01h is always ignored. 70 freq1 freq0 en10bit freq2 0 add9 add8 0 intclk range (mhz) freq2 freq1 freq0 2.5-6000 6- 10 0 0 1 10-14010 14-30011 30-50100 70 dr7 dr6 dr5 dr4 dr3 dr2 dr1 dr0 70 adr7 adr6 adr5 adr4 adr3 adr2 adr1 adr0
192/224 st92163 - i2c bus interface i 2 c interface (cont'd) interrupt status register (i2cisr) r248 - read / write register page: 20 reset value: 1xxx xxxx (xxh) bit 7 = dmastop dma suspended mode . this bit selects between dma suspended mode and dma not suspended mode. in dma suspended mode, if the error interrupt pending bit (i2cisr.ierrp) is set, no dma re- quest is performed. dma requests are performed only when ierrp=0. moreover the aerror condi- tiono interrupt source has a higher priority than the dma. in dma not-suspended mode, the status of ierrp bit has no effect on dma requests. moreo- ver the dma has higher priority with respect to oth- er interrupt sources. 0: dma not-suspended mode 1: dma suspended mode bit 6:4 = prl[2:0] interrupt/dma priority bits . the priority is encoded with these three bits. the value of a0o has the highest priority, the value a7o has no priority. after the setting of this priority lev- el, the priorities between the different interrupt/ dma sources is hardware defined according with the following scheme: error condition interrupt (if dmastop=1) (high- est priority) receiver dma request transmitter dma request error condition interrupt (if dmastop=0 data received/receiver end of block peripheral ready to transmit/transmitter end of block (lowest priority) bit 3 = reserved. must be cleared. bit 2 = ierrp error condition pending bit 0: no error 1: error event detected (if ite=1) note: depending on the status of the i2cisr.dmastop bit, this flag can suspend or not suspend the dma requests. note: the interrupt pending bits can be reset by writing a a0o but is not possible to write a a1o. it is mandatory to clear the interrupt source by writing a a0o in the pending bit when executing the interrupt service routine. when serving an interrupt routine, the user should reset only the pending bit related to the served interrupt routine (and not reset the other pending bits). to detect the specific error condition that oc- curred, the flag bits of the i2csr1 and i2csr2 register should be checked. note: the ierrp pending bit is forced high until the error event flags are set (adsl and sb flags in the i2csr1 register, sclf, addtx, af, stopf, arlo and berr flags in the i2csr2 register). if at least one flag is set, it is not possible to reset the ierrp bit. bit 1 = irxp data received pending bit 0: no data received 1: data received (if ite=1). bit 0 = itxp peripheral ready to transmit pend- ing bit 0: peripheral not ready to transmit 1: peripheral ready to transmit a data byte (if ite=1). 70 dmastop prl2 prl1 prl0 0 ierrp irxp itxp
193/224 st92163 - i2c bus interface i 2 c interface (cont'd) interrupt vector register (i2civr) r249 - read / write register page: 20 reset value: undefined bit 7:3 = v[7:3] interrupt vector base address . user programmable interrupt vector bits. these are the five more significant bits of the interrupt vector base address. they must be set before en- abling the interrupt features. bit 2:1 = ev[2:1] encoded interrupt source . these read-only bits are set by hardware accord- ing to the interrupt source: 01: error condition detected 10: data received 11: peripheral ready to transmit bit 0 = reserved. forced by hardware to 0. receiver dma source address pointer register (i2crdap) r250 - read / write register page: 20 reset value: undefined bit 7:1 = ra[7:1] receiver dma address pointer . i2crdap contains the address of the pointer (in the register file) of the receiver dma data source when the dma is selected between the peripheral and the memory space. otherwise, (dma between peripheral and register file), this register has no meaning. see section 8.5.6.1 for more details on the use of this register. bit 0 = rps receiver dma memory pointer selec- tor . if memory has been selected for dma transfer (ddcrdc.rf/mem = 0) then: 0: select isr register for receiver dma transfer address extension. 1: select dmasr register for receiver dma trans- fer address extension. receiver dma transaction counter register (i2crdc) r251 - read / write register page: 20 reset value: undefined bit 7:1 = rc[7:1] receiver dma counter pointer. i2crdc contains the address of the pointer (in the register file) of the dma receiver transaction counter when the dma between peripheral and memory space is selected. otherwise (dma be- tween peripheral and register file), this register points to a pair of registers that are used as dma address register and dma transaction counter. see section 8.5.6.1 and section 8.5.6.2 for more details on the use of this register. bit 0 = rf/mem receiver register file/ memory selector. 0: dma towards memory 1: dma towards register file 70 v7 v6 v5 v4 v3 ev2 ev1 0 70 ra7 ra6 ra5 ra4 ra3 ra2 ra1 rps 70 rc7 rc6 rc5 rc4 rc3 rc2 rc1 rf/mem
194/224 st92163 - i2c bus interface i 2 c interface (cont'd) transmitter dma source address pointer register (i2ctdap) r252 - read / write register page: 20 reset value: undefined bit 7:1= ta[7:1] transmit dma address pointer. i2ctdap contains the address of the pointer (in the register file) of the transmitter dma data source when the dma between the peripheral and the memory space is selected. otherwise (dma between the peripheral and register file), this reg- ister has no meaning. see section 8.5.6.2 for more details on the use of this register. bit 0 = tps transmitter dma memory pointer se- lector . if memory has been selected for dma transfer (ddctdc.rf/mem = 0) then: 0: select isr register for transmitter dma transfer address extension. 1: select dmasr register for transmitter dma transfer address extension. transmitter dma transaction coun- ter register (i2ctdc) r253 - read / write register page: 20 reset value: undefined bit 7:1 = tc[7:1] transmit dma counter pointer . i2ctdc contains the address of the pointer (in the register file) of the dma transmitter transaction counter when the dma between peripheral and memory space is selected. otherwise, if the dma between peripheral and register file is selected, this register points to a pair of registers that are used as dma address register and dma transac- tion counter. see section 8.5.6.1 and section 8.5.6.2 for more details on the use of this register. bit 0 = rf/mem transmitter register file/ memo- ry selector. 0: dma from memory 1: dma from register file extended clock control register (i2ceccr) r254 - read / write register page: 20 reset value: 0000 0000 (00h) bit 7:2 = reserved. must always be cleared. bit 1:0 = cc[8:7] 9-bit divider programming implementation of a programmable clock divider. these bits and the cc[6:0] bits of the i2cccr reg- ister select the speed of the bus (f scl ). for a description of the use of these bits, see the i2cccr register. they are not cleared when the interface is disa- bled (i2cccr.pe=0). 70 ta7 ta6 ta5 ta4 ta3 ta2 ta1 tps 70 tc7 tc6 tc5 tc4 tc3 tc2 tc1 rf/mem 70 0 00 000cc8cc7
195/224 st92163 - i2c bus interface i 2 c interface (cont'd) interrupt mask register (i2cimr) r255 - read / write register page: 20 reset value: 00xx 0000 (x0h) bit 7 = rxdm receiver dma mask . 0: dma reception disable. 1: dma reception enable rxdm is reset by hardware when the transaction counter value decrements to zero, that is when a receiver end of block interrupt is issued. bit 6 = txdm transmitter dma mask . 0: dma transmission disable. 1: dma transmission enable. txdm is reset by hardware when the transaction counter value decrements to zero, that is when a transmitter end of block interrupt is issued. bit 5 = reobp receiver dma end of block flag . reobp should be reset by software in order to avoid undesired interrupt routines, especially in in- itialization routine (after reset) and after entering the end of block interrupt routine.writing a0o in this bit will cancel the interrupt request note: reobp can only be written to a0o. 0: end of block not reached. 1: end of data block in dma receiver detected bit 4 = teobp transmitter dma end of block te- obp should be reset by software in order to avoid undesired interrupt routines, especially in initializa- tion routine (after reset) and after entering the end of block interrupt routine.writing a0o will cancel the interrupt request. note: teobp can only be written to a0o. 0: end of block not reached 1: end of data block in dma transmitter detected. bit 3 = reserved. this bit must be cleared. bit 2 = ierrm error condition interrupt mask bit. this bit enables/ disables the error interrupt. 0: error interrupt disabled. 1: error interrupt enabled. bit 1 = irxm data received interrupt mask bit. this bit enables/ disables the data received and receive dma end of block interrupts. 0: interrupts disabled 1: interrupts enabled note: this bit has no effect on dma transfer bit 0 = itxm peripheral ready to transmit inter- rupt mask bit. this bit enables/ disables the peripheral ready to transmit and transmit dma end of block inter- rupts. 0: interrupts disabled 1: interrupts enabled note: this bit has no effect on dma transfer. 70 rxd m txd m reobp teobp 0 ierr m irx m itx m
196/224 st92163 - i2c bus interface i 2 c interface (cont'd) table 36. i 2 c bus register map and reset values address (hex.) register name 765 4 3210 f0h i2ccr reset value - 0 - 0 pe 0 engc 0 start 0 ack 0 stop 0 ite 0 f1h i2csr1 reset value evf 0 add10 0 tra 0 busy 0 btf 0 adsl 0 m/sl 0 sb 0 f2h i2csr2 reset value - 0 0 0 addtx 0 af 0 stopf 0 arlo 0 berr 0 gcal 0 f3h i2cccr reset value fm/sm 0 cc6 0 cc5 0 cc4 0 cc3 0 cc2 0 cc1 0 cc0 0 f4h i2coar1 reset value add7 0 add6 0 add5 0 add4 0 add3 0 add2 0 add1 0 add0 0 f5h i2coar2 reset value freq1 0 freq0 0 en10bit 0 freq2 0 0 0 add9 0 add8 0 0 0 f6h i2cdr reset value dr7 0 dr6 0 dr5 0 dr4 0 dr3 0 dr2 0 dr1 0 dr0 0 f7h i2cadr reset value adr7 1 adr6 0 adr5 1 adr4 0 adr3 0 adr2 0 adr1 0 adr0 0 f8h i2cisr reset value dmasto p 1 prl2 x prl1 x prl0 xx ierrp x irxp x itxp x f9h i2civr reset value v7 x v6 x v5 x v4 x v3 x ev2 x ev1 x 0 0 fah i2crdap reset value ra7 x ra6 x ra5 x ra4 x ra3 x ra2 x ra1 x rps x fbh i2crdc reset value rc7 x rc6 x rc5 x rc4 x rc3 x rc2 x rc1 x rf/mem x fch i2ctdap reset value ta7 x ta6 x ta5 x ta4 x ta3 x ta2 x ta1 x tps x fdh i2ctdc reset value tc7 x tc6 x tc5 x tc4 x tc3 x tc2 x tc1 x rf/mem x feh i2ceccr 0 0 0 0 0 0 0 0 0 0 0 0 cc8 0 cc7 0 ffh i2cimr reset value rxdm 0 txdm 0 reobp x teobp x0 ierrm 0 irxm 0 itxm 0
197/224 st92163 - a/d converter (a/d) 8.6 a/d converter (a/d) 8.6.1 introduction the 8 bit analog to digital converter uses a fully differential analog configuration for the best noise immunity and precision performance. the analog voltage references of the converter are connected to the internal av dd &av ss analog supply pins of the chip if they are available, otherwise to the ordi- nary v dd and v ss supply pins of the chip. the guaranteed accuracy depends on the device (see electrical characteristics). a fast sample/hold al- lows quick signal sampling for minimum warping effect and conversion error. 8.6.2 main features n 8-bit resolution a/d converter n single conversion time (including sampling time): 138 internal system clock periods in slow mode (~5.6 m s @25mhz internal system clock); 78 intclk periods in fast mode (~6.5 m s@ 12mhz internal system clock) n sample/hold: tsample= 84 intclk periods in slow mode (~3.4 m s @25mhz internal system clock) 48 intclk periods in fast mode (~4 m s @12mhz internal system clock) n up to 8 analog inputs (the number of inputs is device dependent, see device pinout) n single/continuous conversion mode n external/internal source trigger (alternate synchronization) n power down mode (zero power consumption) n 1 control logic register n 1 data register 8.6.3 general description depending on the device, up to 8 analog inputs can be selected by software. different conversion modes are provided: single, continuous, or triggered. the continuous mode performs a continuous conversion flow of the se- lected channel, while in the single mode the se- lected channel is converted once and then the log- ic waits for a new hardware or software restart. a data register (addtr) is available, mapped in page 62, allowing data storage (in single or contin- uous mode). the start conversion event can be managed by software, writing the start/stop bit of the con- trol logic register or by hardware using either: an external signal on the extrg triggered input (negative edge sensitive) connected as an alter- nate function to an i/o port bit an on chip event generated by another periph- eral, such as the mft (multifunction timer). figure 86. a/d converter block diagram n st9 bus succe ssive approxi mation register analog mux data regist er control logic s/h ain1 ainx intrg (on chip event) ain0 extrg
198/224 st92163 - a/d converter (a/d) a/d converter ( cont'd ) the conversion technique used is successive ap- proximation, with ac coupled analog fully differen- tial comparators blocks plus a sample and hold logic and a reference generator. the internal reference (dac) is based on the use of a binary-ratioed capacitor array. this technique allows the specified monotonicity (using the same ratioed capacitors as sampling capacitor). a pow- er down programmable bit sets the a/d converter analog section to a zero consumption idle status. 8.6.3.1 operating modes the two main operating modes, single and contin- uous, can be selected by writing 0 (reset value) or 1 into the cont bit of the control logic register. single mode in single mode (cont=0 in adclr) the str bit is forced to '0' after the end of channel i-th conver- sion; then the a/d waits for a new start event. this mode is useful when a set of signals must be sam- pled at a fixed frequency imposed by a timer unit or an external generator (through the alternate synchronization feature). a simple software rou- tine monitoring the str bit can be used to save the current value before a new conversion ends (so to create a signal samples table within the in- ternal memory or the register file). furthermore, if the r242.0 bit (register ad-int, bit 0) is set, at the end of conversion a negative edge on the con- nected external interrupt channel (see interrupts chapter) is generated to allow the reading of the converted data by means of an interrupt routine. continuous mode in continuous mode (cont=1 in adclr) a con- tinuous conversion flow is entered by a start event on the selected channel until the str bit is reset by software. at the end of each conversion, the data register (adcdr) content is updated with the last conver- sion result, while the former value is lost. when the conversion flow is stopped, an interrupt request is generated with the same modality previously de- scribed. 8.6.3.2 alternate synchronization this feature is available in both single/continuous modes. the negative edge of external extrg sig- nal or the occurrence of an on-chip event generat- ed by another peripheral can be used to synchro- nize the conversion start with a trigger pulse. these events can be enabled or masked by pro- gramming the trg bit in the adclr register. the effect of alternate synchronization is to set the str bit, which is cleared by hardware at the end of each conversion in single mode. in continuous mode any trigger pulse following the first one will be ignored. the synchronization source must pro- vide a pulse (1.5 internal system clock, 125ns @ 12 mhz internal clock) of minimum width, and a period greater (in single mode) than the conver- sion time (~6.5us @ 12 mhz internal clock). if a trigger occurs when the str bit is still '1' (conver- sions still in progress), it is ignored (see electrical characteristics). warning: if the extrg or intrg signals are al- ready active when trg bit is set, the conversion starts immediately. 8.6.3.3 power-up operations before enabling any a/d operation mode, set the pow bit of the adclr register at least 60 m s be- fore the first conversion starts to enable the bias- ing circuits inside the analog section of the con- verter. clearing the pow bit is useful when the a/d is not used so reducing the total chip power consumption. this state is also the reset configu- ration and it is forced by hardware when the core is in halt state (after a halt instruction execution). 8.6.3.4 register mapping it is possible to have two independent a/d convert- ers in the same device. in this case they are named a/d 0 and a/d 1. if the device has one a/d converter it uses the register addresses of a/d 0. the register map is the following: if two a/d converters are present, the registers are renamed, adding the suffix 0 to the a/d 0 registers and 1 to the a/d 1 registers. register address adn page 62 (3eh) f0h a/d 0 addtr0 f1h a/d 0 adclr0 f2h a/d 0 adint0 f3-f7h a/d 0 reserved f8h a/d 1 addtr1 f9h a/d 1 adclr1 fah a/d 1 adint1 fb-ffh a/d 1 reserved
199/224 st92163 - a/d converter (a/d) a/d converter ( cont'd ) 8.6.4 register description a/d control logic register (adclr) r241 - read/write register page: 62 reset value: 0000 0000 (00h) this 8-bit register manages the a/d logic opera- tions. any write operation to it will cause the cur- rent conversion to be aborted and the logic to be re-initialized to the starting configuration. bit 7:5 = c[2:0] : channel address. these bits are set and cleared by software. they select channel i conversion as follows: bit 4 = fs : fast/slow . this bit is set and cleared by software. 0: fast mode. single conversion time: 78 x intclk (5.75 m s at intclk = 12 mhz) 1: slow mode. single conversion time: 138 x intclk (11.5 m s at intclk = 12 mhz) note : fast conversion mode is only allowed for in- ternal speeds which do not exceed 12 mhz. bit 3 = trg : external/internal trigger enable . this bit is set and cleared by software. 0: external/internal trigger disabled. 1: either a negative (falling) edge on the extrg pin or an on chip event writes a a1o into the str bit, enabling start of conversion. note: triggering by on chip event is available on devices with the multifunction timer (mft) periph- eral. bit 2 = pow : power enable . this bit is set and cleared by software. 0: disables all power consuming logic. 1: enables the a/d logic and analog circuitry. bit 1 = cont : continuous/single mode select . this bit it set and cleared by software. 0: single mode: after the current conversion ends, the str bit is reset by hardware and the con- verter logic is put in a wait status. to start anoth- er conversion, the str bit has to be set by soft- ware or hardware. 1: select continuous mode, a continuous flow of a/d conversions on the selected channel, start- ing when the str bit is set. bit 0 = str : start/stop . this bit is set and cleared by software. it is also set by hardware when the a/d is synchronized with an external/internal trigger. 0: stop conversion on channel i. an interrupt is generated if the str was previously set and the ad-int bit is set. 1: start conversion on channel i warning: when accessing this register, it is rec- ommended to keep the related a/d interrupt chan- nel masked or disabled to avoid spurious interrupt requests. a/d channel i data register (addtr) r240 - read/write register page: 62 reset value: undefined the result of the conversion of the selected chan- nel is stored in the 8-bit addtr, which is reloaded with a new value every time a conversion ends. 70 c2 c1 c0 fs trg pow cont str c2 c1 c0 channel enabled 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 channel 0 channel 1 channel 2 channel 3 channel 4 channel 5 channel 6 channel 7 70 r.7 r.6 r.5 r.4 r.3 r.2 r.1 r.0
200/224 st92163 - a/d converter (a/d) a/d converter ( cont'd ) a/d interrupt register (adint) register page: 62 r242 - read/write reset value: 0000 0001 (01h) bit 7:1 = reserved. bit 0 = ad-int : ad converter interrupt enable . this bit is set and cleared by software. it allows the interrupt source to be switched between the a/d converter and an external interrupt pin (see inter- rupts chapter). 0: a/d interrupt disabled. external pin selected as interrupt source. 1: a/d interrupt enabled 70 0000000 ad-int
201/224 st92163 - electrical characteristics 9 electrical characteristics the st92163 device contains circuitry to protect the inputs against damage due to high static volt- age or electric field. nevertheless it is advised to take normal precautions and to avoid applying to this high impedance voltage circuit any voltage higher than the maximum rated voltages. it is rec- ommended for proper operation that v in and v out be constrained to the range: v ss ( v in or v out ) v dd to enhance reliability of operation, it is recom- mended to connect unused inputs to an appropri- ate logic voltage level such as v ss or v dd . all the voltages in the following table, are refer- enced to v ss . absolute maximum ratings note : stresses above those listed as aabsolute maximum ratingsa may cause permanent damage to the device. this is a stress rating only and functional operation of the device at these conditions is not implied. exposure to maximum rating conditions for extended periods may affect device reliability. all voltages are referenced to v ss recommended operating conditions (normal voltage mode, all devices) note 1. 1mhz when a/d is used recommended operating conditions (low voltage modes, devices with suffix l or v)) note 1. 1mhz when a/d is used symbol parameter value unit v dd supply voltage 0.3 to +7.0 v v i input voltage 0.3 to v dd +0.3 v v ai analog input voltage (a/d converter) v ss - 0.3 to v dd +0.3 av ss - 0.3 to av dd +0.3 v v o output voltage 0.3 to v dd +0.3 v t stg storage temperature 55 to + 150 c i inj pin injection current digital and analog input -5 to +5 ma maximum accumulated pin injection current in the device -50 to +50 ma av dd a/d converter analog reference v dd -0.3 to v dd +0.3 v av ss a/d converter v ss v ss -0.3 to v ss +0.3 v symbol parameter value unit min. max. t a operating temperature 0 70 c v dd operating supply voltage 4.0 5.5 v f intclk internal clock frequency @ 4.0v - 5.5v 0 (1) 24 mhz symbol parameter value unit min. max. t a operating temperature 0 70 c v dd operating supply voltage 3.0 4.0 v f intclk internal clock frequency @ 3.0v - 4.0v 8-mhz low voltage devices (devices with suffix l) 0 (1) 8 mhz 16-mhz low voltage devices (devices with suffix v) 0 (1) 16 mhz
202/224 st92163 - electrical characteristics dc electrical characteristics (v dd = 4.0 - 5.5v, t a =0 c+70 c, unless otherwise specified) *for devices with suffix l or v, these characteristics are valid for v dd = 3.0 - 5.5v note: all i/o ports are configured in bidirectional weak pull-up mode with no dc load external clock pin (oscin ) is driven by square wave external clock. no peripheral working. symbol parameter test conditio ns value unit min. typ. max. v ihck * clock input high level external clock 0.7 v dd v dd + 0.3 v v ilck * clock input low level external clock 0.3 0.3 v dd v v ih * input high level ttl 2.0 v dd + 0.3 v cmos 0.7 v dd v dd + 0.3 v v il * input low level ttl 0.3 0.8 v cmos 0.3 0.3 v dd v v ihrs * reset input high level 0.7 v dd v dd + 0.3 v v ilrs * reset input low level 0.3 0.3 v dd v v hyrs * reset input hysteresis 0.3 1.5 v v oh * output high level push pull, iload = 0.8ma v dd 0.8 v v ol output low level push pull or open drain, iload = 1.6ma 0.4 v output low level high sink pins (port 6) iload = 10ma 1 v i wpu weak pull-up current bidirectional weak pull-up, v ol = 0v 40 200 420 m a i apu active pull-up current, for int0 and int7 only v in < 0.8v, under reset 80 200 420 m a i lkio * i/o pin input leakage input/tri-state, 0v < v in 203/224 st92163 - electrical characteristics ac electrical characteristics (v dd = 4.0 - 5.5v, t a =0 c+70 c, unless otherwise specified) (v dd = 3.0 - 3.3 v, t a =0 c+70 c ) note: all i/o ports are configured in bidirectional weak pull-up mode with no dc load, external clock pin (oscin) is driven by square wave external clock (1) preliminary value (2) external pull-up (1.5 kohms connected to usbv cc ); operating conditions: v dd = 4.0 - 5.25v ; t a =25 c ac test conditions symbol parameter v dd max unit i dd run mode current @ 24 mhz 85 (1) ma i wfi wfi mode @ 24 mhz 20 (1) ma i halt halt mode current 100 m a i susp usb suspend mode current (2) 450 m a symbol parameter v dd unit typ max i dd run mode current 1.2 1.4 ma/mhz i wfi wfi mode 0.3 0.4 ma/mhz i halt halt mode current 100 m a ttl input forcing conditi on cmos input forcing conditi on push-pull output test condition weak pull-up output test condit ion source current = -0.8ma 1 sink current = -1.6ma 0 1 source current = 0 sink current = 1.6ma 2.4v 0.45v 0.8v dd 0.2v dd 3.0v 0.8v 3.0v 0.8v
204/224 st92163 - electrical characteristics electrical characteristics (cont'd) * not available on devices with suffix l, v or e **guaranteed by design n/a = not applicable low voltage detector reset electrical specifications* symbol parameter conditions min typ max unit v lvdup lv reset trigger v dd rising edge intclk = 16mhz 3.5 3.7 3.9 v v lvddown lv reset trigger v dd falling edge 3.3 3.5 3.7 v v lvdhyst hysteresis ** 150 200 250 mv i 2 c interface electrical specifications parameter symbol standard mode i2c fast mode i2c unit min max min max low level input voltage: fixed input levels v dd -related input levels v il -0.5 -0.5 1.5 0.3 v dd -0.5 -0.5 1.5 0.3 v dd v high level input voltage: v dd -related input levels 0.7 v dd v dd +0.5 0.7 v dd v dd +0.5 v hysteresis of schmitt trigger inputs fixed input levels v dd -related input levels v hys n/a n/a n/a n/a 0.2 0.05 v dd v pulse width of spikes which must be sup- pressed by the input filter t sp n/a n/a 0 ns 50 ns ns low level output voltage (open drain and open collector) at 3 ma sink current at 6 ma sink current v ol1 v ol2 0 n/a 0.4 n/a 0 0 0.4 0.6 v output fall time from vih min to vil max with a bus capacitance from 10 pf to 400 pf with up to 3 ma sink current at v ol1 with up to 6 ma sink current at v ol2 t of n/a 250 n/a 20+0.1cb 20+0.1cb 250 250 ns input current each i/o pin with an input voltage between 0.4v and 0.9 v dd max i - 10 10 -10 10 m a capacitance for each i/o pin c 10 10 pf
205/224 st92163 - electrical characteristics electrical characteristics (cont'd) 1)the device must internally provide a hold time of at least 300 ns for the sda signal in order to bridge the unde- fined region of the falling edge of scl 2)the maximum hold time of the start condition has only to be met if the interface does not stretch the low period of scl signal cb = total capacitance of one bus line in pf i 2 c bus timings parameter symbol standard i 2 c fast i 2 c unit min max min max bus free time between a stop and start con- dition t buf 4.7 1.3 m s hold time start condition. after this period, the first clock pulse is generated t hd:sta 4.0 0.6 m s low period of the scl clock t low 4.7 1.3 m s high period of the scl clock t high 4.0 0.6 m s set-up time for a repeated start condition t su:sta 4.7 0.6 m s data hold time t hd:dat 0 (1) 0 (1) 0.9(2) ns data set-up time t su:dat 250 100 ns rise time of both sda and scl signals t r 1000 20+0.1cb 300 ns fall time of both sda and scl signals tf 300 20+0.1cb 300 ns set-up time for stop condition t su : sto 4.0 0.6 ns capacitive load for each bus line cb 400 400 pf
206/224 st92163 - electrical characteristics usb interface: dc characteristics (v dd = 4.0 - 5.5v, t a =0 c+70 c, unless otherwise specified) rl is the load connected on the usb drivers. all voltages are measured from the local ground potential (usbgnd). usb interface: dc electrical characteristics parameter symbol condition s min. max. unit inputs levels: differential input sensitivity v di i(d+, d-) 0.2 v differential common mode range v cm includes v di range 0.8 2.5 v single ended receiver threshold v se 0.8 2.0 v output levels static output low v ol rl of 1.5k ohms to 3.6v 0.3 v static output high v oh rl of 15k ohm to gnd 2.8 3.6 v usbvcc: voltage level usb v v dd =5v 2.97 3.63 v hi-z state data line leakage i lo 0 v < vin < 3.3 v (regulator on) -10 +10 m a
207/224 st92163 - electrical characteristics electrical characteristics (cont'd) figure 87. usb interface: data signal rise and fall time usb interface: full speed characteristics (v dd = 4.0 - 5.5v, t a =0 c+70 c, unless otherwise specified) 1) measured from 10% to 90% of the data signal differential data lines usbgnd tf tr crossover points vcrs usb interface: full speed electrical characteristics parameter symbol condition s min max unit driver characteristics: rise time tr cl=50 pf 1) 420ns fall time tf cl=50 pf 1) 420ns rise/ fall time matching trfm tr/tf 90 110 % output signal crossover voltage vcrs 1.3 2.0 v
208/224 st92163 - electrical characteristics external interrupt timing table (v dd = 3.0 - 5.5v (1) ,t a =0 c+70 c, c load = 50pf, f intclk = 24mhz, unless otherwise specified) note : the value in the left hand column shows the formula used to calculate the timing minimum or maximum from the oscillator clock period. the value in the right hand two columns show the timing minimum and maximum for an internal clock at 24mhz (intclk). (1) 3.0 - 4.0v voltage range is only available on devices with suffix l or v, with different frequency limitatio ns (l: 8 mhz, v: 16 mhz) (2) formula guaranteed by design. legend : tck = intclk period = oscin period when oscin is not divided by 2; 2 x oscin period when oscin is divided by 2; oscin period x pll factor when the pll is enabled. external interrupt timing n symbol parameter value (note) unit formula (2) min max 1 twintlr low level pulse width in rising edge mode tck+10 50 ns 2 twinthr high level pulse width in rising edge mode tck+10 50 ns 3 twinthf high level pulse width in falling edge mode tck+10 50 ns 4 twintlf low level pulse width in falling edge mode tck+10 50 ns
209/224 st92163 - electrical characteristics wake-up management timing table (v dd = 3.0 - 5.5v (1) ,t a =0 c+70 c, c load = 50pf, f intclk = 24mhz, unless otherwise specified) note : the value in the left hand column shows the formula used to calculate the timing minimum or maximum from the oscillator clock period. the value in the right hand two columns show the timing minimum and maximum for an internal clock at 24mhz (intclk). the given data are related to wake-up management unit used in external interrupt mode. (1) 3.0 - 4.0v voltage range is only available on devices with suffix l or v, with different frequency limitatio ns (l: 8 mhz, v: 16 mhz) (2) formula guaranteed by design. legend : tck = intclk period = oscin period when oscin is not divided by 2; 2 x oscin period when oscin is divided by 2; oscin period x pll factor when the pll is enabled. wake-up management timing n symbol parameter value (note) unit formula (2) min max 1 twwkplr low level pulse width in rising edge mode tck+10 50 ns 2 twwkphr high level pulse width in rising edge mode tck+10 50 ns 3 twwkphf high level pulse width in falling edge mode tck+10 50 ns 4 twwkplf low level pulse width in falling edge mode tck+10 50 ns wkupn n=0 15
210/224 st92163 - electrical characteristics rccu characteristics (v dd = 3.0 - 5.5v (1) ,t a =0 c+70 c, c load = 50pf, f intclk = 24mhz, unless otherwise specified) (1) 3.0 - 4.0v voltage range is only available on devices with suffix l or v, with different frequency limitatio ns (l: 8 mhz, v: 16 mhz) rccu timing table (v dd = 3.0 - 5.5v (1) ,t a =0 c+70 c, c load = 50pf, f intclk = 24mhz, unless otherwise specified) (1) 3.0 -4.0v voltage range is only available on devices with suffix l or v, with different frequency limitations (l: 8 mhz, v:16 mhz) (2) depending on the delay between rising edge of resetn pin and the first rising edge of clock1, the value can differ from the typical value for +/- 1 clock1 cycle. legend :t osc = oscin clock cycles pll characteristics (v dd = 3.0 - 5.5v (1) ,t a =0 c+70 c, c load = 50pf, f intclk = 24mhz, unless otherwise specified) (1) 3.0 - 4.0v voltage range is only available on devices with suffix l or v, with different frequency limitatio ns (l: 8 mhz, v: 16 mhz) (2) measured at 24mhz (intc lk). guaranteed by design characterisation (not tested). legend : tosc = oscin clock cycles symbol parameter comment value (note) unit min typ max v ihrs reset input high level 0.7 x v dd v dd + 0.3 v v ilrs reset input low level 0.3 0.3 x v dd v v hyrs reset input hysteresis 0.3 0.9 1.5 v i lkrs reset pin input leakage 0v < v in 211/224 st92163 - electrical characteristics oscillator characteristics (v dd = 3.0 - 5.5v (1) ,t a =0 c+70 c, c load = 50pf, f intclk = 24mhz, unless otherwise specified) (1) 3.0 - 4.0v voltage range is only available on devices with suffix l or v, with different frequency limitatio ns (l: 8 mhz, v: 16 mhz) symbol parameter comment value (note) unit min typ max f osc crystal frequency fundamental mode crystal only 3 8 mhz g m oscillator v dd = 4.0 - 5.5 v 0.77 1.5 2.4 ma/v v dd = 3.0 - 4.0 v 0.5 0.73 1.47 ma/v v ihck clock input high level external clock 0.8 x v dd v dd + 0.3 v v ilck clock input low level external clock 0.3 0.2 x v dd v i lkos oscin/oscout pin input leakage 0v < v in 212/224 st92163 - electrical characteristics external bus timing table (v dd = 3.0 - 5.5v (1) ,t a =0 c+70 c, c load = 50pf, f intclk = 24mhz, unless otherwise specified) note: the value in the left hand column shows the formula used to calculate the timing minimum or maximum from the oscillator clock period, prescaler value and number of wait cycles inserted. the values in the right hand two columns show the timing minimum and maximum for an external clock at 24mhz, prescaler value of zero and zero wait states. (1) 3.0 - 4.0v voltage range is only available on devices with suffix l or v, with different frequency limitatio ns (l: 8 mhz, v: 16 mhz) legend : tck = intclk period = oscin period when oscin is not divided by 2; 2 x oscin period when oscin is divided by 2; oscin period x pll factor when the pll is enabled. tckh = intclk high pulse width (normally = tck/2, except when intclk = oscin, in which case it is oscin high pulse width) tckl = intclk low pulse width (normally = tck/2, except when intclk = oscin, in which case it is oscin low pulse width) p = clock prescaling value (=prs; division factor = 1+p) wa = wait cycles on as; = max (p, programmed wait cycles in emr2, requested wait cycles with wait) wd = wait cycles on ds; = max (p, programmed wait cycles in wcr, requested wait cycles with wait) n symbol parameter value (note) unit formula min max 1 tsa (as) address set-up time before as tck x wa+tckh-9 12 ns 2 thas (a) address hold time after as tckl-4 17 ns 3 tdas (dr) as to data available (read) tck x (wd+1)+3 45 ns 4 twas as low pulse width tck x wa+tckh-5 16 ns 5 tdaz (ds) address float to ds 00ns 6 twds ds low pulse width tck x wd+tckh-5 16 ns 7 tddsr (dr) ds to data valid delay (read) tck x wd+tckh+4 25 ns 8 thdr (ds) data to ds hold time (read) 7 7 ns 9 tdds (a) ds to address active delay tckl+11 32 ns 10 tdds (as) ds to as delay tckl-4 17 ns 11 tsr/w (as) rw set-up time before asn tck x wa+tckh-17 4 ns 12 tddsr (r/w) ds to rw and address not valid delay tckl-1 20 ns 13 tddw (dsw) write data valid to ds delay -16 -16 ns 14 tsd(dsw) write data set-up before ds tck x wd+tckh-16 5 ns 15 thds (dw) data hold time after ds (write) tckl-3 18 ns 16 tda (dr) address valid to data valid delay (read) tck x (wa+wd+1)+tckh-7 55 ns 17 tdas (ds) as to ds delay tckl-6 15 ns
213/224 st92163 - electrical characteristics external bus timing cpuclk rw port1 port0 (read) as ds port0 (write)
214/224 st92163 - electrical characteristics watchdog timing table (v dd = 3.0 - 5.5v (1) ,t a =0 c+70 c, c load = 50pf, f intclk = 24mhz, push-pull output configuration, unless otherwise specified) note : the value in the left hand column shows the formula used to calculate the timing minimum or maximum from the oscillator clock period, watchdog prescaler and counter programmed values. the value in the right hand two columns show the timing minimum and maximum for an internal clock (intclk) at 24mhz, with minimum and maximum prescaler value and minimum and maximum counter value. (1) 3.0 - 4.0v voltage range is only available on devices with suffix l or v, with different frequency limitatio ns (l: 8 mhz, v: 16 mhz) legend : tck = intclk period = oscin period when oscin is not divided by 2; 2 x oscin period when oscin is divided by 2; oscin period x pll factor when the pll is enabled. psc = watchdog prescaler register content (wdtpr): from 0 to 255 cnt = watchdog couter registers content (wdtrh,wd trl): from 0 to 65535 t wdin = watchdog input signal period (wdin) watchdog timing n symbol parameter value (note) unit formula min max 1 twwdol wdout low pulse width 4 x (psc+1) x (cnt+1) x tck 167 2.8 ns s (psc+1) x (cnt+1) x t wdin with t wdin 8 x tck 333 ns 2 twwdoh wdout high pulse width 4 x (psc+1) x (cnt+1) x tck 167 2.8 ns s (psc+1) x (cnt+1) x t wdin with t wdin 8 x tck 333 ns 3 twwdil wdin high pulse width 4 x tck 167 ns 4 twwdih wdin low pulse width 4 x tck 167 ns
215/224 st92163 - electrical characteristics multifunction timer external timing table (v dd = 3.0 - 5.5v (1) ,t a =0 c+70 c, c load = 50pf, f intclk = 24mhz, unless otherwise specified) note : the value in the left hand column shows the formula used to calculate the timing minimum or maximum from the oscillator clock period, standard timer prescaler and counter programmed values. the value in the right hand two columns show the timing minimum and maximum for an internal clock (intclk) at 24mhz. (1) 3.0 - 4.0v voltage range is only available on devices with suffix l or v, with different frequency limitatio ns (l: 8 mhz, v: 16 mhz) (2) n = 1 if the input is rising or falling edge sensitive n = 3 if the input is rising and falling edge sensitive (3) in autodiscrimination mode legend : tck = intclk period = oscin period when oscin is not divided by 2; 2 x oscin period when oscin is divided by 2; oscin period x pll factor when the pll is enabled. multifunction timer external timing n symbol parameter value unit note formula min max 1tw ctw external clock/trigger pulse width n x tck n x 42 - ns (2) 2tw ctd external clock/trigger pulse distance n x tck n x 42 - ns (2) 3tw aed distance between two active edges 3 x tck 125 - ns 4tw gw gate pulse width 6 x tck 250 - ns 5tw lba distance between tinb pulse edge and the fol- lowing tina pulse edge tck 42 - ns (3) 6tw lab distance between tina pulse edge and the fol- lowing tinb pulse edge 0-ns (3) 7tw ad distance between two txina pulses 0 - ns (3) 8tw owd minimum output pulse width/distance 3 x tck 125 - ns
216/224 st92163 - electrical characteristics sci timing table (v dd = 3.0 - 5.5v (1) ,t a =0 c+70 c, c load = 50pf, f intclk = 24mhz, unless otherwise specified) (1) 3.0 - 4.0v voltage range is only available on devices with suffix l or v, with different frequency limitatio ns (l: 8 mhz, v: 16 mhz) legend : tck = intclk period = oscin period when oscin is not divided by 2; 2 x oscin period when oscin is divided by 2; oscin period x pll factor when the pll is enabled. sci timing n symbol parameter conditio n value unit min max f rxckin frequency of rxckin 1x mode f intclk /8 mhz 16x mode f intclk /4 mhz tw rxckin rxckin shortest pulse 1x mode 4 x tck s 16x mode 2 x tck s f txckin frequency of txckin 1x mode f intclk /8 mhz 16x mode f intclk /4 mhz tw txckin txckin shortest pulse 1x mode 4 x tck s 16x mode 2 x tck s 1ts ds ds (data stable) before rising edge of rxckin 1x mode reception with rxckin tck / 2 ns 2td d1 txckin to data out delay time 1x mode transmission with external clock c load < 50pf 2.5 x tck ns 3td d2 clkout to data out delay time 1x mode transmission with clkout tbd ns
217/224 st92163 - electrical characteristics a/d converter, external trigger timing table ( v dd = 3.0 - 5.5v (1) ; t a =0to70 c; unless otherwise specified) (1) 3.0 - 4.0v voltage range is only available on devices with suffix l or v, with different frequency limitatio ns (l: 8 mhz, v: 16 mhz) a/d converter. analog parameters table ( v dd = 3.0 - 5.5v (1) ; t a =0to70 c; unless otherwise specified) notes: (*) the values are expected at 25 celsius degrees with v dd =5v (**) 'lsbs' , as used here, as a value of v dd /256 (1) 3.0 - 4.0v voltage range is only available on devices with suffix l or v, with different frequency limitations (l: 8 mhz, v: 16 mhz) (2) including sample time (3) it must be considered as the on-chip series resistance before the sampling capacitor (4) dnl error= max {[v(i) -v(i-1)] / lsb-1} inl error= max {[v(i) -v(0)] / lsb-i} absolute accuracy= overall max conversion error symbol parameter oscin divide by 2;min/max oscin divide by 1; min/max value unit min max t low pulse width 1.5 intclk ns t high pulse distance ns t ext period/fast mode 78+1 intclk m s t str start conversion delay 0.5 1.5 intclk core clock issued by timing controller t low pulse width ns t high pulse distance ns t ext period/fast mode m s t str start conversion delay ns parameter value unit note typ (*) min max (**) analog input range v ss v dd v conversion time fast/slow 78/138 intclk (2) sample time fast/slow 51.5/87.5 intclk power-up time 60 m s resolution 8 bits differential non linearity 0.5 1.5 lsbs (4) integral non linearity 0.5 1.5 lsbs (4) offset error 0.5 1 gain error 0.5 1.5 absolute accuracy 1 2 lsbs (4) input resistance 1.5 kohm (3) hold capacitance 1.92 pf
218/224 st92163 - general information 10 general information 10.1 eprom/otp programming the 20 kbytes of eprom/otp of the st92e163/ ST92T163 may be programmed using the eprom programming boards available from stmicroelectronics. eprom erasing the eprom of the windowed package of the st92e163 can be erased by exposure to ultra-vi- olet light. the erasure characteristic of the st92e163 is such that erasure begins when the memory is ex- posed to light with wave lengths shorter than ap- proximately 4000?. it should be noted that sunlight and some types of fluorescent lamps have wave- lengths in the range 3000-4000?. it is recom- mended to cover the window of the st92e163 packages by an opaque label to prevent uninten- tional erasure problems when testing the applica- tion in such an environment. the recommended erasure procedure of the eprom is the exposure to short wave ultraviolet light which have a wave-length 2537?. the inte- grated dose (i.e. u.v. intensity x exposure time) for erasure should be a minimum of 15w-sec/cm2. the erasure time with this dosage is approximate- ly 30 minutes using an ultraviolet lamp with a 12000 mw/cm2 power rating. the device should be placed within 2.5 cm (1 inch) of the lamp tubes during erasure.
219/224 st92163 - general information 10.2 package description figure 88. 56-pin shrink plastic dual in line package, 600-mil width figure 89. 64-pin thin quad flat package dim. mm inches min typ max min typ max a 6.35 0.250 a1 0.38 0.015 a2 3.18 4.95 0.125 0.195 b 0.41 0.016 b2 0.89 0.035 c 0.20 0.38 0.008 0.015 d 50.29 53.21 1.980 2.095 e 15.01 0.591 e1 12.32 14.73 0.485 0.580 e 1.78 0.070 ea 15.24 0.600 eb 17.78 0.700 l 2.92 5.08 0.115 0.200 number of pins n56 pdip56s dim mm inches min typ max min typ max a 1.60 0.063 a1 0.05 0.15 0.002 0.006 a2 1.35 1.40 1.45 0.053 0.055 0.057 b 0.30 0.37 0.45 0.012 0.015 0.018 c 0.09 0.20 0.004 0.008 d 16.00 0.630 d1 14.00 0.551 d3 12.00 0.472 e 16.00 0.630 e1 14.00 0.551 e3 12.00 0.472 e 0.80 0.031 k 0 3.5 7 l 0.45 0.60 0.75 0.018 0.024 0.030 l1 1.00 0.039 number of pins n 64 nd 16 ne 16 l1 l k 0.10mm .004 seating plane
220/224 st92163 - general information package description (cont'd) figure 90. 56-pin shrink ceramic dual in-line package, 600-mil width figure 91. 64-pin ceramic quad flat package dim. mm inches min typ max min typ max a 4.17 0.164 a1 0.76 0.030 b 0.38 0.46 0.56 0.015 0.018 0.022 b1 0.76 0.89 1.02 0.030 0.035 0.040 c 0.23 0.25 0.38 0.009 0.010 0.015 d 50.04 50.80 51.56 1.970 2.000 2.030 d1 48.01 1.890 e1 14.48 14.99 15.49 0.570 0.590 0.610 e 1.78 0.070 g 14.12 14.38 14.63 0.556 0.566 0.576 g1 18.69 18.95 19.20 0.736 0.746 0.756 g2 1.14 0.045 g3 11.05 11.30 11.56 0.435 0.445 0.455 g4 15.11 15.37 15.62 0.595 0.605 0.615 l 2.92 5.08 0.115 0.200 s 1.40 0.055 number of pins n56 cdip56sw dim mm inches min typ max min typ max a 3.27 0.129 a1 0.50 0.020 b 0.30 0.35 0.45 0.012 0.014 0.018 c 0.13 0.15 0.23 0.005 0.006 0.009 d 16.65 17.20 17.75 0.656 0.677 0.699 d1 13.57 13.97 14.37 0.534 0.550 0.566 d3 12.00 0.472 e 0.80 0.031 g 12.70 0.500 g2 0.96 0.038 l 0.35 0.80 0.014 0.031 0 8.31 0.327 number of pins n64 cqfp064w
221/224 st92163 - general information 10.3 ordering information the following section deals with the procedure for transfer of customer codes to stmicroelectronics. 10.4 transfer of customer code customer code is made up of the rom contents. the rom contents are to be sent on diskette, or by electronic means, with the hexadecimal file generated by the development tool. all unused bytes must be set to ffh. the customer code should be communicated to stmicroelectronics with the correctly completed option list appended. the stmicroelectronics sales organization will be pleased to provide detailed information on con- tractual points. figure 92. sales type coding rules table 37. development tools note 1: the emulator does not support low voltage modes development tool sales type remarks real time emulator 1 st92163-emu2 eprom programming board st92e163-epb/eu st92e163-epb/us 220v power supply 110v power supply gang programmer st92e16x-gp/dip56 st92e16x-gp/qfp sdip56 package tqfp64 package c hiware compiler and debugger st9p-swc/v4 for pc st 92163 r 4 b 1 l / xxx family (92163, 92e163, 92t163) number of pins rom size package temperature range device characteristics rom code (three letters) l = 8-mhz low voltage version 1= standard (0 to +70 c) b = plastic dip 4 = 20k n = 56 pins v = 16-mhz low voltage version 0= 25 c d = ceramic dip r = 64 pins e = without lvd function (for normal voltage versions) g = ceramic qfp no letter = with lvd function (for normal voltage versions)
222/224 st92163 - general information table 38. ordering information note 1: xxx stands for the rom code name assigned by stmicroelectronics note 2: contact sales office for availability note 3: lvm = low voltage mode and nm = normal mode sales type 1) program memory (bytes) mode operating voltage package st92163n4b1/xxx 2) 20k rom normal 4.0-5.5 v psdip56 st92163r4t1/xxx 2) 4.0-5.5 v tqfp64 st92e163n4d0 20k eprom 4.0-5.5 v csdip56 st92e163r4g0 4.0-5.5 v cqfp64 ST92T163n4b1 20k otp 4.0-5.5 v psdip56 ST92T163r4t1 4.0-5.5 v tqfp64 st92163n4b1e/xxx 2) 20k rom 4.0-5.5 v psdip56 st92163r4t1e/xxx 2) 4.0-5.5 v tqfp64 st92e163n4d1e 20k eprom 4.0-5.5 v csdip56 st92e163r4g1e 4.0-5.5 v cqfp64 ST92T163n4b1e 20k otp 4.0-5.5 v psdip56 ST92T163r4t1e 4.0-5.5 v tqfp64 st92163r4t1l/xxx 2) 20k rom normal and 8-mhz low voltage 8-mhz lvm 3) 3.0-4.0 v (@8mhz) tqfp64 nm 3) 4.0-5.5 v st92e163r4g1l 20k eprom 8-mhz lvm 3) 3.0-4.0 v (@8mhz) cqfp64 nm 3) 4.0-5.5 v st92e163n4d1l 8-mhz lvm 3) 3.0-4.0 v (@8mhz) csdip56 nm 3) 4.0-5.5 v ST92T163r4t1l 20k otp 8-mhz lvm 3) 3.0-4.0 v (@8mhz) tqfp64 nm 3) 4.0-5.5 v st92163r4t1v/xxx 2) 20k rom normal, 8-mhz low voltage and 16-mhz low voltage 16-mhz lvm 3) 3.0v-4.0 (@16mhz) 8-mhz lvm 3) 3.0v-4.0 (@8mhz) nm 3) 4.0-5.5v st92e163r4t1v 2) 20k eprom 16-mhz lvm 3) 3.0v-4.0 (@16mhz) cqfp64 8-mhz lvm 3) 3.0v-4.0 (@8mhz) nm 3) 4.0-5.5v st92e163n4d1v 2) 16-mhz lvm 3) 3.0v-4.0 (@16mhz) csdip56 8-mhz lvm 3) 3.0v-4.0 (@8mhz) nm 3) 4.0-5.5v ST92T163r4t1v 2) 20k otp 16-mhz lvm 3) 3.0v-4.0 (@16mhz) tqfp64 8-mhz lvm 3) 3.0v-4.0 (@8mhz) nm 3) 4.0-5.5v
223/224 st92163 - general information stmicroelectronics option list st92163 microcontroller family (rom device) customer: . . . . . . . . . . . . . . . . . . . . ........ address: . . . . . . . . . . . . . . . . . . . . ........ ............................ contact: . . . . . . . . . . . . . . . . . . . . ........ phone no: . . . . . . . . . . . . . . . . . . . . ........ reference/rom code* : . . . . . ............. *the rom code name is assigned by stmicroelectronics. stmicroelectronics reference: device (psdip56): [ ] st92163n4b1/xxx* [ ] st92163n4b1e/xxx* device (tqfp64): [ ] st92163r4t1/xxx* [ ] st92163r4t1e/xxx* [ ] st92163r4t1l/xxx* [ ] st92163r4t1v/xxx* *xxx = rom code name software development: [ ] stmicroelectronics [ ] customer [ ] external laboratory special marking: [ ] no [ ] yes o_ _ _ _ _ ___________o for marking, one line is possible with maximum 13 characters. authorized characters are letters, digits, '.', '-', '/' and spaces only. we have checked the rom code verification file returned to us by stmicroelectronics. it conforms exactly with the rom code file orginally supplied. we therefore authorize stmicroelectronics to proceed with device manufacture. signature . . . . . . . . . . . . . . . . . . . . ........ date . . . . . . . . . . . . . . . . . . . . ........
224/224 st92163 - general information notes: information furnished is believed to be accurate and reliable. however, stmicroelectronics assumes no responsibility for the consequences of use of such information nor for any infringement of patents or other rights of third parties which may result from its use. no license is granted by implication or otherwise under any patent or patent rights of stmicroelectronics. specifications mentioned in this publication are subject to change without notice. this publication supersedes and replaces all information previously supplied. stmicroelectronics products are not authorized for use as critical components in life support devices or systems without the express written approval of stmicroelectronics. the st logo is a registered trademark of stmicroelectronics ? 2000 stmicroelectronics - all rights reserved. purchase of i 2 c components by stmicroelectronics conveys a license under the philips i 2 c patent. rights to use these components in an i 2 c system is granted provided that the system conforms to the i 2 c standard specification as defined by philips. stmicroelectronics group of companies australia - brazil - china - finland - france - germany - hong kong - india - italy - japan - malaysia - malta - morocco - singapore - spain sweden - switzerland - united kingdom - u.s.a. http:// www.st.com


▲Up To Search▲   

 
Price & Availability of ST92T163

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X